The Script will sniff for old and dated or generally incapable browsers and see to it that these won't be broken by too complex script or hyper text markup code, but instead that the clients be diverted to an appropriate message on a simplified web page, or relocated to an alternative section of the site, or be given a simpler script code to interpret. Probably you would like to use fresh technologies, but at the same time not lose visitors, just because not everybody updated their browsers or computers in a while. All this can be accomplished seamlessly by the use of client-side javascript, and all appropriate functions utilized are highly adjustable with this script.
It should preferably be allowed to form part of the site's overall structure. The Script is a great utility for controlling traffic on any site, and especially for webmasters not being able to use server scripts, it (or a similar system) is a necessity. For the Script to work as intended, a few things need to be prepared, but first let's try it out.
If you were to check the source of the current HTML file, you would find that the script
code is placed near to the top in the HEAD
, having already made your browser go and get all the
script data. Now you only have to initiate it, and you can do it by clicking the hyper link below. The script
is using the default settings.
Calling the Init function in this
document's HEAD
Before beginning to integrate the Sniff and Divert Script, there is a few things to prepare.
NOSCRIPT
section
A client will enter your site (or a section of it) at an entry point. This is where you should expect
any browser to come stumbling in. The page at this primary location in the site's structure must
cater for anything, or the site would look poorly designed. Here's where you need the Script,
because it knows all relevant features about old and new browsers alike. You'd need to put a portion of the
script code in the HEAD
section of this document. It should be written in order to not break
any browser in any way. Ten year old impossible applications like Netscape Navigator 2 or
Internet Explorer 3 should instantly be taken care of and nicely turned away from the site towards
the FallBackUponURL, while the remainder should be handled the way you decide with another portion
of the script located in a separate script source file. Both the HEAD
portion and the source file
portion will be dynamically generated by you yourself further down this page.
Note that there is one limitation though; the Sniff and Divert Script knows nothing about the
circa 5-10% of browsers out there going about the web without javascript made available. Therefore you'd need
to prepare the Entry page with a NOSCRIPT
section, as elaborate as you think necessary and
appropriate.
Before beginning to customize the script code, you should know the location for and having prepared an HTML 3.2 web page for dated technologies, which you no longer need to support. That web page are adviced to be one and the same for the whole site, even if the Sniff and Divert Script is used multiple times. As an example, please check the fallback page we use at the PM site.
Since the Entry page is accustomed to all sorts of browsers, standards and non-standards alike, it's advicable to keep it simple and save the flashy stuff for subsections of the site, only when you know exactly which browser technology being at hand. The Script is utilizing methods to deal with the relocation of diverse technologies to specific subsections of the site.
The Script will make the current location change to another location in a subdirectory of the
originating directory (by default keeping the name of the original file) or to another file in the same
directory. It will do this applying either the method location =
"SomeURL"
or the optional method
location.replace("SomeURL")
. In the first instance the browser is
"moving on" to another location and thereby marking a new entry in the history sequence, compared
to the second instance, where the browser rather would "replace" the current history mark with
another.
The Script doesn't make the relocation compulsory, though. It may easily be configured to deal with many kinds of alternate scripts, and yet remaining at the current location. Then we say the mode of the Script is in Script Action mode rather than Relocation mode.
To work, the Script depends on one or two external script source files, and the mandatory of these is ready-made (30 kB) in no need of modifications. There is a hyperlinked document that will bring you info about the ready-made source file.
The second and optional source file, which you are supposed to generate yourself by use of the form below, contains the custom-made parts of the Sniff and Divert Script.
Now is the time to customize and test the script, and furthermore possibly create the generated script source file CustomScriptFile.js. Further down this page, you could click a button to have the script code generated already this very minute, but of course you should adapt it to your site.s particular needs, which is quickly accomplished by filling out the form.
Having selected and pasted the generated code (see the form above) in the HEAD
section of the
entry page
the script could be initiated by the use of an event handler, such as
onLoad or onClick. The function to call is "Init".
<BODY onload="Init()"> or <BUTTON onclick="Init()">
For the case the script will do nothing, i.e. JavaScript is not enabled or the
browser hasn't implemented the script language, you would need to provide the web page content within
NOSCRIPT
tags. Preferably this web page should be written using HTML3.2 or HTML4 Transitional code. To facilitate maintenance of the site, I suggest use of the
same code here as on yourRegularLocation:
<noscript> your Web Page Content For Browsers Not JavaScript Enabled </noscript>
That's it. No more frustrated surfers will choose another website or even send you angry emails.
© 2001-2005 The Script is FREE FOR USE if author info is provided.