• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

JavaScript Navigator Object

April 9, 2014 //  by Krishna Srinivasan//  Leave a Comment

The Navigator object specifies information about client’s browser window such as version, mime type and plug-ins. The window.navigator is read only property which gives reference to navigator object which provides information about application running the script. There is no public standard that applies to the navigator object, but all major browsers support it.

JavaScript Navigator Object Syntax

navObj=window.navigator

JavaScript Navigator Object Properties

The following are the properties of Navigator object:

  • appName: It specifies name of the browser.
  • appCodeName: It returns code name of the browser.
  • appVersion: It returns version of the browser.
  • language: It indicates default language of the browser.
  • mimeTypes: it is used to return mime types supported by the browser.
  • platform: It indicates the platform in which browser is running.
  • plugins: It indicates plugins that are installed on the browser.
  • userAgent: It specifies user agent header.

Methods

The following are the methods of Navigator object:

  • javaEnabled: It indicates whether java is enabled or not. It returns boolean value.
  • taintEnabled: It indicates whether data taint is enabled or not.

JavaScript Navigator Object Example

<!DOCTYPE html>
<head>
<meta charset="ISO-8859-1">
<title>JavaScript Navigator</title>
</head>
<body>
	<script type="text/javascript">
		document.write(navigator.appName + "<br>");
		document.write(navigator.appCodeName + "<br>");
		document.write(navigator.appVersion + "<br>");
		document.write(navigator.cookieEnabled + "<br>");
		document.write(navigator.platform + "<br>");
		document.write(navigator.userAgent + "<br>");
	</script>
</body>
</html>
  • <script type=”text/javascript”> tag is used to define client side script which uses attribute type for specifying MIME type.
  • document.write(navigator.appName); line indicates name of the browser.
  • document.write(navigator.appCodeName); line indicates code name of the browser.
  • document.write(navigator.appVersion); line indicates version of the browser.
  • document.write(navigator.cookieEnabled); line indicates if cookies are enabled.
  • document.write(navigator.platform); line indicates the platform in which browser is running.
  • document.write(navigator.userAgent); line indicates user agent header.

JavaScript Navigator Object Demo

  • Save the file as JSnavigator_example.html in your system.
  • Just open the file in the browser, you will see the below picture in the browser.

When the execution process is completed successfully we will get the following output:

JavaScript Navigator Object

Category: JavaScriptTag: JavaScript Tutorials

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: « JavaScript Location Object
Next Post: Javascript Document Object »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact