|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.
3) Various Browsers
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: