Visit Mozilla.org

DOM:element.lang

出典: MDC

« Gecko DOM リファレンス

目次

[編集] 概要

このプロパティは要素の属性値およびテキストコンテンツのベース言語を取得(get)または設定(set)します。

[編集] 構文と値

var languageUsed = elementNodeReference.lang;
elementNodeReference.lang = NewLanguage;

languageUsed is a string variable that gets the language in which the text of the current element is written. NewLanguage is a string variable with its value setting the language in which the text of the current element is written.

[編集]

// 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";
   };

[編集] 注記

このプロパティで返される言語コードは RFC 1766で定義されています。 一般的な例では "en" は英語、 "ja" は日本語、 "es" はスペイン語などです。 この属性のデフォルト値は unknown です。 Note that this attribute, though valid at the individual element level described here, is most often specified for the root element of the document.

[編集] 仕様

W3C DOM Level 2 HTML: lang