- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the code name and product name of the browser in JavaScript?
When a user accesses a web application using JavaScript, the "navigator" object contains details about the browser they are currently using. You may be aware that each browser functions differently when it comes to how it interprets JavaScript. In this case, the navigator object supports in modifying your application to the user's browser preferences.
The browser engine or product name can be viewed in JavaScript by accessing the "navigator.product" attribute of a navigator object. In any browser, "Gecko" is always the value of the Navigator.product property. Only compatibility considerations are used to maintain this characteristic.
Syntax
The JavaScript syntax for the navigator.product property
/regexp/g
Navigator Object navigator.product property
Example 1
In this example let us understand how the navigator navigator.product attribute allows JavaScript to identify the name of the browser. While accessing the "navigator.product" property, newer browsers show "Gecko" as the product name for compatibility concerns.
<!DOCTYPE html> <html> <title>How to get the code name and product name of the browser in JavaScript - TutorialsPoint</title> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="result"></div> <script> let productName = navigator.product; document.getElementById("result").innerHTML ="The output of Browser product is: " + productName; </script> </body> </html>
Navigator Object appCodename property
The JavaScript navigator object's "appCodename" field indicates the identity of the browser. In every browser, "Mozilla" is the output of the Navigator.appCodeName field. The only reason this property is preserved is for compatibility. The "browserCodeName" variable in the example below will be used to hold the browser code name returned by the "navigator.appCodeName" property −
Syntax
The JavaScript syntax for the navigator.appCodename property.
navigator.appCodename
Example 2
In this example let us understand how the navigator navigator.appCodename attribute allows JavaScript to identify the browser code name.
<!DOCTYPE html> <html> <title>How to get the code name and product name of the browser in JavaScript - TutorialsPoint</title> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="result"></div> <script> let codeName = navigator.appCodeName; document.getElementById("result").innerHTML ="The output of Browser Code Name is: " + codeName; </script> </body> </html>
- Related Articles
- How to get the application name and version information of a browser in JavaScript?
- How to get the colour name from colour code in R?
- How to get the data type name from the java.sql.Type code using JDBC?
- With JavaScript how can I find the name of the web browser, with version?
- How to share code between Node.js and the browser?
- How to get the name of the current executable in C#?
- How to know the browser language and browser platform in JavaScript?
- How to find the name and the target of a form in JavaScript?
- Get the name of the file and path in Java
- How to get the class name of an instance in Python?
- How can my code discover the name of an object in Python?
- How to get the widget name in the event in Tkinter?
- How to get details of a webpage like url, title name, domain name etc using Javascript Executor in Selenium?
- C# Program to get the name of the drive
- Get the size of the screen, current web page and browser window in JavaScript
