

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 know the browser language and browser platform in JavaScript?
Javascript has provided navigator object to know any details regarding the browser. It has provided navigator.platform and navigator.language to get the details regarding the platform and language of the browser respectively. Let's discuss each of them individually.
Browser-platform
syntax
platform = navigator.platform;
Example
To get the platform on which browser works, the navigator object has provided navigator.platform. some of the platforms are "MacIntel", "Win32", "WebTV OS".
<html> <body> <script> document.write("browser platform is " + navigator.platform); </script> </body> </html>
Output
browser platform is Win32
Browser-language
syntax
language = navigator.language;
Example
To get the language of the browser, the navigator object has provided navigator.language method. We can change the language depending on our convenience. Some of the most commonly used languages are en-GB and en-US
<html> <body> <p id="language"></p> <script> document.getElementById("language").innerHTML = "browser language is " + navigator.language; </script> </body> </html>
Output
"browser language is en-US
- Related Questions & Answers
- Introduction to browser events in JavaScript
- How to maximize the browser in Selenium?
- JavaScript Detecting a mobile browser
- How to get the code name and product name of the browser in JavaScript?
- How can I make a browser to browser (peer to peer) connection in HTML?
- How to get the application name and version information of a browser in JavaScript?
- How to detect if JavaScript is disabled in a browser?
- How to change Firefox Browser theme?
- How to find the inner height and inner width of a browser window in JavaScript?
- How to perform browser navigations in Selenium?
- How to Resize Browser Window in WebDriver?
- How does the browser identify inline JavaScripts?
- How to find whether a browser supports JavaScript or not?
- How to disable browser's back button with JavaScript?
- How to detect whether the browser is online or offline with JavaScript?
Advertisements