![]() |
![]() |
|
|
||
If you have syndicated content delivered with JavaScript, the increasing number of folks who turn their browser's JavaScript off can be a concern. Syndicated content, in this article, means HTML content (text, images, forms, and so forth) delivered from a remote site and published on your page with JavaScript code similar to: <script language="JavaScript" src="http://domain.com/file.js"> </script> On our various sites, the percentage of visitors with non-JavaScript enabled browsers averages about 5%. This may be significant, depending on how important the content is to your site. If you merely want to deliver a notice to non-JavaScript enabled browsers, the following on your page will do the job: <noscript> <h3>JavaScript required to view this content.</h3> </noscript> However, if you want to display the syndicated content to all browsers, this article will show you how. Why They Turn It Off During the last six months, every person who has told me s/he now surfs with JavaScript turned off is doing so because of the interruptive popups they were encountering. If you feel you must use popups on your site, "Pop-Under Windows The Latest Pop-Window Trend" by Shelley Lowery presents methods to reduce visitor irritation. You'll find the article at http://www.web-source.net/popunder.htm How To Deliver Syndicated Content To All Browsers Instead of putting JavaScript code into your page, like the code presented above, use SSI (Server Side Includes). Your SSI page calls a script. The script retrieves the content and inserts it into your page. The SSI tag is <!--#exec cgi="/cgi-bin/JStoSSI.cgi"--> Replace "/cgi-bin/JStoSSI.cgi" with the location and name of the script on your server. (The script is presented below.) On many servers, pages with SSI need to have file names with the .shtml extension. Your server may be different. Contact your hosting company if in doubt. For additional information about about SSI, see the "Server Side Includes" article linked from http://willmaster.com/possibilities/archives/ The Script Here is the script your web page will call with the SSI tag:
#!/usr/bin/perl
my $JavaScriptURL = 'http://domain.com/file.js';
use strict;
use LWP::Simple;
my $content = get $JavaScriptURL;
my @content = split /[\r\n]+/,$content;
chomp @content;
for(@content)
{
unless(/^document/) { $_ = ''; next; }
$_ =~ s/^document\.writeln\(\'//;
$_ =~ s/\'\)\;$//;
$_ =~ s/\\\'/'/g;
$_ =~ s/\\\\/\\/g;
}
$content = join "\n",@content;
print "Content-type: text/html\n\n$content";
# end of script
Use a plain text word processor like NotePad or BBEdit to edit the first two lines of the script.
Next, upload the script to your server. Upload it as ASCII/plain text to a directory that can run CGI scripts. In this article's examples, it is assumed you're uploading the script into the cgi-bin directory and that the file name of the script is JStoSSI.cgi, but you're not restricted to that. NOTE: The above script requires the Perl module LWP::Simple. If you are unsure whether or not your server has the module installed, ask your hosting company or use Master Pre-Installation Tester from http://willmaster.com/master/pit/ Review A. If you were inserting syndicated content into your pages with JavaScript, the JavaScript would look something like this: <script language="JavaScript" src="http://domain.com/file.js"> </script> B. To use the SSI method instead:
Your SSI page will probably need the .shtml file name extension. Your Own Syndicated Content If you want to publish content that others are syndicating, see: The SSI method of inserting syndicated content presented in this article, in lieu of the JavaScript method of insertion, will work with many syndication content sources including both of those listed above. If you want to syndicate your content to other web sites, see:
The SSI method presented in this article will work with the methods of creating syndicated content found at the three URLs, above. If you are a webmaster syndicating content, you may wish to provide your remote syndication sites with the opportunity to use the SSI method. Simply send this article to them. By: Will Bontrager Copyright 2002 Bontrager Connection, LLC
| ||