Navigator Object


You can access information about the browser through the properties exposed by the navigator object. Please, note, all of its properties are read-only.

appCodeName

Returns the code name of the application. Internet Explorer returns Mozilla.

appName

Returns the name of the application. Internet Explorer  returns Microsoft Internet Explorer.

appVersion

Returns the version of the application. Internet Explorer 3.0 returns 2.0 (compatible; MSIE 3.0; Windows 95). Internet Explorer 5.0 working under Windows98 returns 4.0 (compatible; MSIE 5.0; Windows 98;DigExt).

userAgent

Returns the user agent of the application. Internet Explorer 5.0 returns Mozilla/4.0 (compatible; MSIE 5.0; Windows 98;DigExt)..

The most practical use of the navigator object involves detecting whether the client is using Internet Explorer or another browser. Say that you have prepared an HTML page that can be viewed with any browser, and a more advanced version of the same page that makes use of scripts and style sheets. These  features are supported by only Internet Explorer 5.0. You can easily detect which browser the client has running and display the appropriate page. The code might be as follows:

<SCRIPT LANGUAGE=VBScript> 
If window.navigator.appname="Microsoft Internet Explorer" Then 
window.navigate "InternetExplorerPage.htm" 
</SCRIPT>
The copyright of the article Navigator Object in VB Script is owned by Maxim Karetnikov. Permission to republish Navigator Object in print or online must be granted by the author in writing.

Go To Page: 1

Articles in this Topic    Discussions in this Topic