You are here: Reference > JavaScript > client-side > browser > properties > browserLanguage (clientInformation, navigator)
browserLanguage property (clientInformation, navigator)
Returns the language of the browser application or the operating system's user interface.
In older versions of Internet Explorer, this property retrieves the language of the browser application.
From Internet Explorer 5, this property returns the language of the operating system's user interface.
In Opera, the browserLanguage property always returns the language of the browser application.
There are other properties that contain information about the user's language settings:
- The language property returns the language of the browser application in Firefox, Opera, Google Chrome and Safari.
- The systemLanguage property returns the language edition of the operating system in Internet Explorer
- The userLanguage property returns the current Regional and Language settings of the operating system in Internet Explorer and the language of the browser application in Opera.
If you need to detect the type of the user's browser, please see the page for Browser detection.
To get various information about the browser and the operating system of the user, please see the page for the navigator object and the example below.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
String that represents the language.
Default: this property has no default value.
Example HTML code 1:
This example displays various language settings:
|
||||
<head> <script type="text/javascript"> function GetLangInfo () { var message = ""; message += "Language of the browser: " + window.navigator.language; message += "<br />Operating system: " + window.navigator.platform; if (window.navigator.language === undefined) { // in Opera, the language, browserLanguage and userLanguage properties are equivalent message += "<br />Language of the operating system's user interface: " + window.navigator.browserLanguage; message += "<br />Regional and Language settings of the operating system: " + window.navigator.userLanguage; } message += "<br />Language of the installed operating system: " + window.navigator.systemLanguage; var output = document.getElementById ("output"); output.innerHTML = message; } </script> </head> <body onload="GetLangInfo ();"> <div id="output"></div> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example displays various information about the browser and the operating system of the user:
|
||||
<head> <script type="text/javascript"> function AddRowToInfo (description, value) { if (value !== undefined) { var infoTable = document.getElementById ("info"); var row = infoTable.insertRow (-1); var cell = row.insertCell (-1); cell.innerHTML = description; cell.style.paddingRight = "10px"; cell = row.insertCell (-1); cell.innerHTML = value; cell.style.paddingLeft = "10px"; } } function GetVisitorInfo () { AddRowToInfo ("Name of the browser (appName)", window.navigator.appName); AddRowToInfo ("Name of the browser vendor (vendor)", window.navigator.vendor); AddRowToInfo ("Code name of the browser (appCodeName)", window.navigator.appCodeName); AddRowToInfo ("Engine of the browser (product)", window.navigator.product); AddRowToInfo ("Build number of the browser engine (productSub)", window.navigator.productSub); if (window.opera) { AddRowToInfo ("Build number of the browser (buildNumber)", window.opera.buildNumber ()); AddRowToInfo ("Version number of the browser (version)", window.opera.version ()); } AddRowToInfo ("Version and platform of the browser (appVersion)", window.navigator.appVersion); AddRowToInfo ("Version of the browser given by the vendor (vendorSub)", window.navigator.vendorSub); AddRowToInfo ("Minor version of the browser (appMinorVersion)", window.navigator.appMinorVersion); AddRowToInfo ("Build identifier of the browser (buildID)", window.navigator.buildID); AddRowToInfo ("User-agent request header (userAgent)", window.navigator.userAgent); AddRowToInfo ("Language of the browser (language)", window.navigator.language); AddRowToInfo ("Cookies are enabled (cookieEnabled)", window.navigator.cookieEnabled); AddRowToInfo ("Operating system (platform)", window.navigator.platform); if (window.navigator.language === undefined) { // in Opera, the language, browserLanguage and userLanguage properties are equivalent AddRowToInfo ("Language of the operating system's user interface (browserLanguage)", window.navigator.browserLanguage); AddRowToInfo ("Regional and Language settings of the operating system (userLanguage)", window.navigator.userLanguage); } AddRowToInfo ("Language of the installed operating system (systemLanguage)", window.navigator.systemLanguage); AddRowToInfo ("Class of CPU (cpuClass)", window.navigator.cpuClass); AddRowToInfo ("Information about the OS and CPU (oscpu)", window.navigator.oscpu); AddRowToInfo ("System is online (onLine)", window.navigator.onLine); } </script> </head> <body onload="GetVisitorInfo ();"> <table id="info" cellpadding="0px" cellspacing="0px" border="1px" style="empty-cells:show;"> <colgroup> <col style="background-color: #e0a0b0;" /> <col /> </colgroup> <tbody> </tbody> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments