
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
What is the role of Navigator object in JavaScript?
To get information about the browser your webpage is currently running in, use the built-in navigator object. You can use various Navigator methods and properties with the object.
Example
You can try to run the following code to implement Navigator object in JavaScript −
<html> <head> <title>Navigator Object Example</title> </head> <body> <script> <!-- var userAgent = navigator.userAgent; var opera = (userAgent.indexOf('Opera') != -1); var ie = (userAgent.indexOf('MSIE') != -1); var gecko = (userAgent.indexOf('Gecko') != -1); var netscape = (userAgent.indexOf('Mozilla') != -1); var version = navigator.appVersion; if (opera) { document.write("Opera based browser"); // Keep your opera specific URL here. } else if (gecko) { document.write("Mozilla based browser"); // Keep your gecko specific URL here. } else if (ie) { document.write("IE based browser"); // Keep your IE specific URL here. } else if (netscape) { document.write("Netscape based browser"); // Keep your Netscape specific URL here. } else { document.write("Unknown browser"); } // You can include version to along with any above condition. document.write("<br /> Browser version info : " + version ); //--> </script> </body> </html>
- Related Articles
- What is the importance of Navigator Object in JavaScript?
- What is the role of the window.history object in JavaScript?
- What is the role of Browser Object Model (BOM) in JavaScript?
- What is the role of clearTimeout() function in JavaScript?
- What is the role of throw statement in JavaScript?
- What is the role of pageXOffset property in JavaScript?
- What is the role of filter() method in JavaScript?
- What is the role of scrollY property in JavaScript?
- What is the role of scrollX property in JavaScript?
- What is the role of parseFloat() method in JavaScript?
- What is the role of parseInt() method in JavaScript?
- What is the role of deferred scripts in JavaScript?
- What is the role of exec method in JavaScript RegExp?
- What is the role of global RegExp property in JavaScript?
- What is the role of source RegExp property in JavaScript?

Advertisements