WbWizard's JS Book

Blue Line

Lesson 14: Navigator

Today we will discuss how to detect what type of browser a visitor to your page is using in order to create sites that work in one form or another for everyone. There are dozens of types/versions/levels of browsers being used today to surf the internet, and each has it's own peculiarities, abilities, and limitations. Nowhere is this cross browser compatibility more of an issue than when using various scripting languages to interact with the user via these disparate browsers. However, with proper planning, a site can be created that uses various techniques to create a seemless experience for the visitor regardless of the browser (or system for that matter) being used.
[Note-some web-surfers prefer to surf the internet with JavaScript disabled for various reasons, and these techniques will help your pages to deliver usable content to these visitors as well.]

1) Non JavaScript Browsers

A) No JavaScript Interpreter
While the vast majority of browsers today have some support for JavaScript (in fact most have JavaScript as the default scripting lanuage), there are a few browsers being used today that have no support for JavaScript, and a few web-surfers who still use older versions of browsers with no support for JavaScript. If your pages rely on JavaScript heavily to function, you must create either non scripted page versions or warnings that the page will not work for the browser being used. HTML offers the <noscript> tag as one solution, example:

B) Browsers with JavaScript Disabled
The warning example shown above will work to warn those who surf without JavaScript enabled in most JavaScript capable browsers that they need to enable it. However, WebTv doesn't seem to recognize the noscript tag when scripting is disabled (ironic, and this may change with the feb upgrade), but does recognize the <noframes> tag when scripting is disabled due to what is commonly referred to as the WebTv Bug which affects many browser features including JavaScript, example:

2) JavaScript Versions
There are currently more than two dozen versions of JavaScript in use on the internet. Most of these have been designed with good backwards compatibility in mind, but with virtually no cross browser compatibility in mind, while others have virtually no regard for the level of scripting, but have features taken from several platforms giving them a semblance of cross browser compatibility that falls apart under heavy scripting. For those pages designed for specific levels of JavaScript browsers, you can use the JavaScript version in the

So what's the difference, and why the new version? With the 1.2 version, you could use negative values, but not with the 1.0 version. Also in 1.0 it was more confusing, due to the charachter at position "from" being included in the new string, but the charachter at position "to" not included, the charachter at "to"-1 is the final charachter. The 1.2 version includes both "start" and "end" charachters and is a more precise method with greater flexibility due to negative ordinate handling ability. Don't worry if this example confuses, just understand that various browsers have levels of JavaScript that work differently, and you must be prepared to script accordingly if you desire cross level compatibility.

3) Various Browsers
There are about a dozen individual browsers in common use today on the internet, and just as each level or version of the JavaScript any browser understands differs, these individual browsers also interpret JavaScript in various ways. In order to create cross browser compatible sites, you will need to prepare for this by writing your scripts to recognize and redirect or script accordingly. The navigator object contains all the information you need to determine the browser being used so you can create scripts which handle any visitor.

A) Dynamic Object
Some webpage developers attempt to create what is commonly referred to as a "Dynamic Object", which is a constructed object (using new Object();) which is created by the script based upon the properties of the navigator object. Such an example is beyond the scope of a single post, and the entire concept is a work in process, so you should familiarize yourself with the methods involved by visiting various sites which attempt to create dynamic objects, and we will move on to what we can easily cover here.

B) Navigator Object
The Navigator object contains read only information about the web browser being used by the visitor. The six main properties one can access via the navigator object are (listed with WebTv values for a new model Sony Plus at level 2.5.5):
navigator.appName = WebTV Plus Receiver
navigator.appVersion = 3.0 (WebTV;2.5.5)
navigator.userAgent = Mozilla/3.0 WebTV/2.5.5 (Compatible; MSIE 2.0)
navigator.appCodeName = bowser
navigator.platform = WebTV OS
navigator.language = undefined

By parsing these properties, your scripts can determine the exact browser, version, platform, and OS the visitor is using and interact or display the page accordingly.

Example script that only allows WebTv Plus units to use a TVML page:

The navigator object also contains references to arrays which contain lists of the plugins and mime-types the visitor's browser has in their arrays, allowing you to check that the visitor can display all the files your page uses:


The navigator object can check for Java compatibility and data-tainting security:


Easy Pad

Blue Line
Lessons by
Jerry aka WebWizard