Broad Network


DOM Navigation Object

DOM Windows and Related Objects – Part 2

Forward: In this part of the series, we look at the DOM Navigation Object.

By: Chrysanthus Date Published: 31 Jul 2012

Introduction

This is part 2 of my series, DOM Windows and Related Objects. In this part of the series, we look at the DOM Navigation Object. I assume you have read the previous part of the series; this is a continuation.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent, etc.), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

The Navigation Object
The navigation object contains information about the browser, like browser name and browser version. It does not deal with the URL of the document. It is the location object that deals with the URL of the document. The navigation object has properties and methods.

Accessing the Navigation Object Properties
The syntax to access a navigation object property is:

    navigation.property

The platform Property
The platform property returns the platform (core operating system) in which the browser is operating. Read and try the following code:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>

</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.platform);
    </script>
</body>
</html>

The appName Property
The appName property returns the name of the browser. The browser is an application. An application is a very large program. The core of an application may be some other person’s (or company’s) application, and it is the name of the core application that the appName property returns. So with the Mozilla Firefox browser, the appName property returns the name, “Netscape”. Netscape is the name of an old browser. In IE6 the name returned is, “Microsoft Internet Explorer”. Read and try the following code:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.appName);
    </script>
</body>
</html>

The appVersion Property
The appVersion property returns the version of the browser. What is returned, is a decimal number and some text in brackets. Read and try the following code:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.appVersion);
    </script>
</body>
</html>

The appCodeName Property
The appCodeName property returns the code name of the browser. I tried the following code with IE, Mozilla Firefox and Opera and I had, “Mozilla”. You read and try the code, yourself, with your browser:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.appCodeName);
    </script>
</body>
</html>

Navigator userAgent Property
The browser is an example of a user agent. A user agent is an application that can display HTML Documents. The browser is like the official or most popular html user agent. The userAgent property returns the value of the user-agent header sent by the browser to the server.

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.userAgent);
    </script>
</body>
</html>

Accessing the Navigation Object Methods
The syntax to access a navigation object method is:

    navigation.method()

The javaEnabled() Method
The javaEnabled() navigation method returns a Boolean value that specifies whether the browser has Java enabled. Read and try the following code:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.javaEnabled());
    </script>
</body>
</html>

The taintEnabled() Method
The taintEnabled() navigation method returns a Boolean value that specifies whether the browser has data tainting enabled. Read and try the following code:

<!DOCTYPE HTML>
<html>
<head>
    <title>Illustration</title>
</head>
<body>
    <p>text text text</p>
    <script type="text/ECMAScript">
        alert(navigator.taintEnabled());
    </script>
</body>
</html>

That is it for the DOM Navigation Object. We stop here and continue in the next part of the series.

Chrys

Related Links

Major in Website Design
Web Development Course
HTML Course
CSS Course
ECMAScript Course
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message