• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The navigator Object

The navigator object, also called the clientInformation object in IE4+, refers to the browser itself. In early versions of the Netscape Navigator, the navigator object actually functioned as the top-level object, although that role has now been taken over by the window object. As we’ve already seen in earlier chapters, the navigator object is often a very useful one in cross-browser programming. We’ve used the navigator object’s appName, appVersion, and userAgent properties to get information about the browser as far back as Chapter 1, “Essential JavaScript,” as with this script (Listing 01-07.html on the web site) which displays the values of those properties:

<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> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint