The Browser and Environment Client-Side JavaScript Sniff and Divide Script, version 3.3 (Easy Options)

What does it do?

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, since it's a great utility for redirecting traffic on any site, and for webmasters not being able to use server scripts, it is even more precious.

The script is applying a detection script kept in an external script source file. To learn about that file, read the uaenvirsniff.js manpage.

To let the detection script generate a list of the objects and properties created by functions kept in the file, along with the values found in the currently used browser of yours, go to the demonstration page.

Time to apply it

The Entry Page and 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 should cater for anything. Here's where you utmost need the script, because it sniffs out all relevant features about old and new browsers alike. On this page a part of the script is put, which ought to not break any browser in any way. Very old applications like Netscape Navigator 3 or Internet Explorer 3 would instantly be taken care of and nicely turned away from the site towards the FallBackUponURL, while all other browsers are handled the way you decide.

If the browser is one of the about 5-10% surfing the web without JavaScript available, like Lynx, ordinary hypertext links (anchors) will substitute for the otherwise automatically accomplished relocations. Therefore you'd need to prepare the Entry page with a NOSCRIPT section, as elaborate as you think necessary and appropriate to point the visitor to the hyperlinks. Do you see a "This is a test NOSCRIPT message [...]" in the next paragraph? If not, your browser skipped the contents between the NOSCRIPT tags, which indicates that your browser is currently script enabled.

MyNextLocation and MyOtherLocation (optional)

The Entry page being accustomed to all browsers should be kept simple, while the technically advanced stuff being better located at subsections of the site. The script is utilizing methods to deal with the relocation of diverse technologies to specific subsections of the site. By default the script would make ECMAScript (edition 1) compliant browsers make the current location change to another location in a subdirectory (optionally keeping the name of the original file) or simply go on to another file anywhere in the directory structure.

The script is not all about relocation, though. It optionally lets itself be configured to deal with customized script code, and yet let the client remain in the same location. If so, we may call it a "Developer perspective", since you are then actually applying your own scripts to the Sniff and Divide Script structure. A relocation, on the other hand, only intending to go on to MyNextLocatio, not caring about alternative pages, may be seen as a "Personal perspective", fit for personal home pages, while the "Business perspective" cannot afford to do without MyOtherLocation as well.

MyFallBackUponURL (required)

Before applying the Sniff and Divide Script, you would need to prepare an HTML 3.2 web page for dated technologies. That web page could preferably be one and the same for the whole site, even though the script is applied several times. Here is an example of a fall-back page.

Deciding on the Script’s options

There are certain things that are already been decided upon, thereby making life easier for all of us. After all, this is the "Easy Options" version of the Sniff and Divide Script ;-) Most important, you could be sure of that browsers not complying with at least edition 1 of ECMAScript will be turned away from the site towards MyFallBackUponURL. This is not only an important requirement for this script to work as intended. It will also make you free to use any ECMAScript compliant code on your site and be confident that it will work. The down-side is that people using Netscape Navigator versions earlier than 4.06 will not be able to browse your pages. Well, they are used to it; perhaps your site is the first to have the courtesy to bring them a fall-back page rather than just let their browser crash.

If the above scenario is exactly what you want, i.e. diverting very old browsers away from the site and letting all others go forward, then you could skip the green field below, quickly move down to fill in the paths on your site, and a little bit further down, generate the code by pressing a button. It's as simple as that.

¬ Safe mode
¬ Business perspective: Divide Location mode (default)
Modifying the requirements for access to your site (works with business mode)

Restrictive approach — Check the box (unchecked by default) to divert all browsers older than the "fifth generation", like Internet Explorer before version 5, Netscape Navigator before version 6.2 and Opera before version 7, to the fall-back page, allowing only 21st Century browsers on the site.

Modify the DOM requirement for MyNextLocation/MyOtherLocation. Add one or several extra requirements for MyNextLocation. For example you may want to reserve this part of the site for computers having access to Java technology and the use of high resolution screens. Then first select java in the drop-down menu, and then also muchspace. Cp. the changes in the grey field.
&& envir.

Browsers not meeting the requirement described and selected above will instead be targeted to MyOtherLocation.

¬ Personal perspective: Simply Divert mode
¬ Developer perspective: Execute My Code mode
Applying the use of an alternative page or code (works with developer mode)
Apply Mixed mode (Alternative Page) — Check the box (unchecked by default) to bring browsers less script capable onward to MyOtherLocation.
(This option is enabled only in developer mode.)
Apply Double mode (Alternative Code) — Check the box (unchecked by default) to let browsers less script capable interpret simpler code.
(This option is enabled only in developer mode.)

But you might like to customize the settings — click here to open a new field

Site Entries Settings

Controlling the Admittance for Dated Browser Products

You may alternatively choose a permissive (default) or a restrictive approach by selecting the adequate option below. The restrictive approach would give access to your site for browsers sometimes referred to as "fifth generation" browsers only. The table shows the details:

IE6 IE5 IE4 Op7.5 Op6 Fx1.0 NS6.2 NC4.8 NN3 Lynx
<5 Permissive OK OK* OK* OK OK* OK OK* OK* Fall-­Back Anchor
=5 Restrictive OK OK* Fall-­Back OK Fall-­Back OK OK* Fall-­Back Fall-­Back Anchor

*) Dependent on the existence of it, some browsers would be targeted towards MyOtherLocation.

The current value of the requirement variable exclusionOption is

You may fine-tune the admittance settings specifically for the Trident and Gecko products.

The current value of the requirement variable exclusionTrident =

The current value of the requirement variable exclusionGecko =


If you intend to use your own JavaScript code with the Sniff and Divide Script, you should insert your own custom-made script commands in the "EDITABLE SECTION" of the by then already generated script code. Script commands conformant with ECMAScript, i.e. at least JavaScript language 1.3 or JScript version 3.0, is required by default.

— Yes, I would like to use my own scripts — Check the box (unchecked by default) to integrate your own JavaScript code with the ScriptAction function.

Having opted for this requirement, you could make more adjustments below.

Adjusting the ECMAScript requirement

You might want to adjust (strengthen) the required ECMAScript version from edition 1 to edition 3, i.e. be able to use JavaScript language 1.5 rather than 1.3, since any browser keeping a script engine not compliant with edition 3, would be turned away from the site before getting in touch with your code. The table shows the details:

IE6 IE5 IE4 Op7.5 Op6 Fx1.0 NS6.2 NC4.8 NN3 Lynx
1 ed. 1 Code Code Code* Code Code* Code Code Code* Fall-­Back NOSCRIPT
2 ed. 3 Code Fall-­Back* Fall-­Back* Code Fall-­Back* Code Code Fall-­Back* Fall-­Back NOSCRIPT

*) Dependent on the existence of it, some browsers would be targeted towards MyOtherLocation, get a fall-back code of yours, or be diverted to the fall-back page.

The current value of the requirement variable restrictScript is


Controlling the Admittance for Limited Hardware and Software

You may add access restrictions on the basis of hardware and software. By default the script implements no such limits. Please note that in Safe, Developer Mixed and Developer Double modes, changes done here have no effect.

Particular operating system If MyNextLocation requires the use of a particular operating system, you should state that requirement in the combo box below.
&& envir.

Computer operating systems not meeting the requirement will instead be targeted to MyOtherLocation.

Check this box (unchecked by default), if screens smaller than 800x600 pixels should be diverted to MyFallBackUponURL.

Show more options

The screen size requirement for entering the site will be as stated here.
Current value of the requirement variable restrictScreenSize =

Check this box (unchecked by default), if screens less than 256 colours should be diverted to MyFallBackUponURL.

Show more options

The screen colour requirement for entering the site will be as stated here.
Current value of the requirement variable restrictScreenColor =

Check this box (unchecked by default), if browsers with poor CSS support, e.g. Netscape Communicator (version 4.x), should be diverted to MyFallBackUponURL.

Show more options

The estimated CSS2 requirement for entering the site will be as stated here.
Current value of the requirement variable restrictOS =

» » »


| | | | | 

Having opted for these requirements, you would need to decide on and type the paths.

The path to the custom script source file (if applied)

If you generated code for a custom script source file, then type the relative path to it on your server in the field below. Type both the directory path and the optionally changed file name. Leave the left field blank if the file is placed in the same directory as the Entry page:
[../]


Uncheck this box (will be checked when code is generated above) if you do not intend to apply a custom script source file, i.e instead have all customized code contained with the Entry page rather than parts of the script code in an external source file.

Finalize the Script and HTML Code

Parts of the Sniff and Divide Script code must be put in the actual HTML document. In this section you will fine-tune the code to put in the HEAD and BODY sections of the Entry page.

Deciding on and typing the paths

The path to the ready-made script source file

Type the relative directory path on your server to where the ready-made script source file is, but note that the file name is added (see the right-hand part of the field). Leave the left-hand part of the field blank if the file should be in the same directory as the Entry page:
[../]

Then right-click and save the most recent edition of this file at the stated location:

Stating MyFallBackUponURL (required)

Some simple browser or computer technologies won't meet any requirements of your site. The location below is where the fall-back document resides.

Type a full URL or a relative location path. The default is a path relative to the current location:
http://some.server.domain/[../]

Stating the path to MyNextLocation (disabled if not applicable)

In most cases, particularly fit browsers will be relocated from the Entry page to another, main site location. The location below is where MyNextLocation document resides.

Type an absolute path, or a relative path like /MySite/MyNextLocation/, or like ../MyNextLocation/. If the path ends with a slash, the script would resolve the file name as the original name from the relocated file.

If you like to use another file name, you should type it next to the path to make it a complete URL. The default is a relative path to the file demo.html located in a sub directory:
http://some.server.domain/[../]

Stating the path to MyOtherLocation (optional)

Occasionally, the browser client might be relocated from the Entry page to another, alternative location on the site. The location below is where the MyOtherLocation resides.

Type an absolute path, or a relative path like /MySite/MyOtherLocation/, or like ../MyOtherLocation/, If the path ends with a slash, the script would resolve the file name as the original name from the relocated file.

If you like to use another file name, you should type it next to the path to make it a complete URL. The default is a relative path to the file demo.html located in a sub directory:
http://some.server.domain/[../]

If the field is locked, and you want to provide an alternative path, you must enable it:
If the field is open, and you don't want to provide an alternative path, you must disable it:

Divert option

The excluded browsers are relocated to MyFallBackUponURL assigned in the document HEAD script. There you'll also find the essential Relocate function, which is at the heart of the script, irrespective of the so-called script mode. By default the script applies the location = "SomeURL" method, if diverting the client to another location, thereby marking another entry into the history sequence.

Check this box (unchecked initially) if you'd like the script to try (not always possible) to apply the location.replace("SomeURL") method instead, thereby causing no extra entry into the history sequence. This would be useful in the case of initiating the script on an onLoad event, then saving the functionality of the Back button.

Generating the script code portion for the Entry page

The textarea above will contain the script code to be placed in the HEAD section of the Entry page. You may choose to have it surrounded by HTML or XHTML tags.

¬ Generating valid HTML (default)
¬ Generating valid XHTML

Having selected and pasted the generated code (see above) in the HEAD section of the Entry page, there is only one easily forgotten – but essential – thing still to do:

Initiating the script

The script should be initiated by the use of an event handler, such as onLoad or onClick. The function to call is "Init", e.g.

 <body onload="Init()"> 

Or...

<!-- Initiates the script -->
<p><a onmouseover="window.status=''; return true" onclick="Init(); return false" 
  href="MyOptionalNoscriptURL.html">Calling Init()</a></p>

 That's it!


© 2001-2008 <larspeemm@netscape.net> · mikaels.net · e-mail · All rights reserved
The script is FREE to be used but NOT to be traded in. International conventions prescribe that author info MUST ALWAYS be provided.

Disclaimer: Please, notice that although the script code is believed to work with all current and correctly working JavaScript browsers, it should be applied with care. There is NO WARRANTY of its proper behaviour, and it is offered to the public AS IS, the author refraining from admitting ANY RESPONSIBILITY WHATSOEVER for unexpected results when use is made of it, EVEN IF USED AS INTENDED. The author would REJECT ANY CLAIM for financial or any other loss supposedly because of it.


top of page