Javascript Navigator Object
The navigator object in JavaScript is used to display information about the version and type of the browser. It can be used to get browser information such as appName, appCodeName, userAgent etc.
Navigator Object Properties :
Property |
Description |
appName |
Returns the code name of the browser. |
appCodeName |
Returns the name of the browser |
appvVersion |
Returns the version of the browser being used |
cookieEnabled |
Returns whether the cookies are enabled or not in the browser |
language |
Returns the language. It is supported in Netscape and Firefox only. |
onLine |
Returns true if browser is online otherwise false. |
plugins |
Returns the plugins. It is supported in Netscape and Firefox only. |
platform |
Returns the platform e.g. Win32. |
systemLanguage |
Returns the system language. It is supported in IE only. |
userAgent |
Returns the user agent |
Example :
<html>
<head>
<title>JavaScript Navigator Object</title>
</head>
<body>
<script type="text/javascript">
document.writeln("navigator.appName: "+navigator.appName + "<br/><br/>");
document.writeln("navigator.appCodeName: "+navigator.appCodeName + "<br/><br/>");
document.writeln("navigator.appVersion: "+navigator.appVersion + "<br/><br/>");
document.writeln("navigator.cookieEnabled: "+navigator.cookieEnabled + "<br/><br/>");
document.writeln("navigator.language: "+navigator.language + "<br/><br/>");
document.writeln("<br/>navigator.onLine: "+navigator.onLine + "<br/><br/>");
document.writeln("<br/>navigator.platform: "+navigator.platform + "<br/><br/>");
document.writeln("<br/>navigator.userAgent: "+navigator.userAgent);
</script>
</body>
</html>
Navigator Object Methods :
Method |
Description |
javaEnabled() |
Whether Java is enabled or not. |
taintEnabled() |
Whether data tainting is enabled or not. |
Example :
<html>
<head>
<title>JavaScript Navigator Object Methods</title>
</head>
<body>
<script type="text/javascript">
document.write("<strong>Java enabled : </strong>" + navigator.javaEnabled() + "<br/><br/>");
document.write("<strong>Data tainting enabled: </strong>" + navigator.taintEnabled());
</script>
</body>
</html>