w3resource logo

JavaScript Client Objects

JavaScript Navigator Object : language

Secondary Nav


The language property of the navigator object is used to detect the language supported by the browser. In general, the value for language is a 2-letter code, define as "en" and sometimes the value for the language is a five-character code, which indicates the language subtype, such as "zh_CN".


Implemented in JavaScript 1.2



Example of Navigator Object : language Property

The following web document shows the browser supported language using language property.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JavaScript navigator  object - language property example</title>
<h1 style="color: red">JavaScript navigator object : language property</h1>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
document.write("navigate language property : " + navigator.language);

View the example of navigator object's language property in the browser

Supported Browser

Internet Explorer 7 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes Yes Yes Yes Yes


See also :

JavaScript Client side objects, methods, properties.

JavaScript Core objects, methods, properties.

Join our Question Answer community to learn and share your programming knowledge.