HTML and CSS Reference
In-Depth Information
The
navigator
object contains properties and methods that describe the browser.
Netscape Navigator and Internet Explorer support the
navigator
object, but some brows-
ers do not.
The
navigator
object can be used for platform-specific checking to determine the version
of the browser being used, whether Java is enabled, what plug-ins are available, and so on.
Table 10.1 lists the properties that describe the
navigator
object.
Table 10.1
Properties of the
navigator
Object
Property
What It Describes
appCodeName
Code name for the browser.
appName
Name of the browser.
appVersion
Version of the browser.
mimeTypes
An array of MIME types supported by the browser.
platform
The operating system where the browser resides.
userAgent
HTTP user-agent header sent from the browser to the server.
EXAMPLE
10.1
<html>
<head><title>Navigator Object</title></head>
<body>
<big>
<script type="text/javascript">
1
for(var property in navigator){
2
str="navigator"+"."+ property;
3
document.write(
property
+ " <em>"+
str
+"</em><br />");
}
</script>
</big>
</body>
</html>
EXPLANATION
1
The special
for
loop assigns, in turn, each property of the
navigator
object to the
variable called
property.
2
A string is created by concatenating “navigator” with a dot and the
property
value.
3
Each property and its value of the
navigator
object is displayed in the browser win-
dow. See Figures 10.4 through 10.7.