diff options
Diffstat (limited to 'files/pt-br/web/api/htmlelement/lang/index.html')
-rw-r--r-- | files/pt-br/web/api/htmlelement/lang/index.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/files/pt-br/web/api/htmlelement/lang/index.html b/files/pt-br/web/api/htmlelement/lang/index.html new file mode 100644 index 0000000000..6f877f1e33 --- /dev/null +++ b/files/pt-br/web/api/htmlelement/lang/index.html @@ -0,0 +1,51 @@ +--- +title: HTMLElement.lang +slug: Web/API/HTMLElement/lang +translation_of: Web/API/HTMLElement/lang +--- +<div>{{ APIRef("HTML DOM") }}</div> + +<p>The <code><strong>HTMLElement.lang</strong></code> property gets or sets the base language of an element's attribute values and text content.</p> + +<p>The language code returned by this property is defined in <a class="external" href="http://tools.ietf.org/html/rfc1766" title="http://tools.ietf.org/html/rfc1766">RFC 1766</a>. Common examples include "en" for English, "ja" for Japanese, "es" for Spanish and so on. The default value of this attribute is <code>unknown</code>. Note that this attribute, though valid at the individual element level described here, is most often specified for the root element of the document.</p> + +<p>This also only works with the <code>lang</code> attribute and not with <code>xml:lang</code>.</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox">var <var>languageUsed</var> = elementNodeReference.lang; // Get the value of lang +elementNodeReference.lang = <var>NewLanguage</var>; // Set new value for lang +</pre> + +<p><var>languageUsed é uma variável string que obtém o idioma no qual o texto do elemento atual é gravado. NewLanguage é uma variável string cujo valor define o idioma no qual o texto do elemento atual é gravado.</var></p> + +<h2 id="Example" name="Example">Exemplo</h2> + +<pre class="brush: js">// this snippet compares the base language and +// redirects to another url based on language +if (document.documentElement.lang === "en") { + window.location.href = "Some_document.html.en"; +} else if (document.documentElement.lang === "ru") { + window.location.href = "Some_document.html.ru"; +}</pre> + +<h2 id="Specification" name="Specification">Especificação</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Status</th> + <th scope="col">Comentário</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('DOM2 HTML', 'html.html#ID-59132807', 'lang')}}</td> + <td>{{Spec2('DOM2 HTML')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<p> </p> |