Inside JavaScript
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.
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
|