The navigator Object


The navigator Object

The navigator object refers to the browser itself, enabling you to determine what browser the user has. In fact, we've already used the navigator object's appName , appVersion , and userAgent properties as far back as Chapter 1, with this script:

(Listing 04-01.html on the web site)
 <HTML>      <HEAD>          <TITLE>              Checking Your Browser Type          </TITLE>      </HEAD>      <BODY>          <SCRIPT LANGUAGE="JavaScript">              document.write("navigator.appName: " + navigator.appName)              document.write("<BR><BR>")              document.write("navigator.appVersion: " + navigator.appVersion)              document.write("<BR><BR>")              document.write("navigator.userAgent: " + navigator.userAgent)          </SCRIPT>          <H1>Checking Your Browser Type</H1>      </BODY>  </HTML> 

You can see the results in Figure 4.3. The navigator object is often a very useful one in cross-browser programming, and we'll use it for that purpose in this chapter.

Figure 4.3. Determining browser type.

graphics/04fig03.gif

You'll find the properties and methods of the navigator object in Table 4.5; it has no events. Not all properties and methods will be supported in all browsers, of course. We'll get the full breakdown on browser version for each property and method in Chapter 10, "Using the navigator , location , and history Objects."

Table 4.5. The Properties and Methods of the navigator Object

Properties

Methods

appCodeName

javaEnabled

appMinorVersion

preference

appName

taintEnabled

appVersion

 

browserLanguage

 

cookieEnabled

 

cpuClass

 

language

 

mimeTypes

 

onLine

 

oscpu

 

platform

 

plugins

 

product

 

productSub

 

securityPolicy

 

systemLanguage

 

userAgent

 

userLanguage

 

userProfile

 

vendor

 

vendorSub

 


Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net