Get the language of your browser:
var x = "Language of the browser: " + navigator.language;
Click the button to display the language of your browser.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww .j a v a 2 s . c om var x = "Language of the browser: " + navigator.language; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The language property returns the language version of the browser.
This property is read-only.
The language property returns a String representing the language version of the browser.
Examples of valid language codes are: "en", "en-US", "de", "fr", etc.