Link hreflangProperty

Link 对象参考手册Link Object

Definition and Usage

The hreflang attribute specifies the language of the text in the linked document.

Syntax

Set the hreflang attribute:

linkObject.hreflang="language-code"

Return the hreflang attribute:

linkObject.hreflang


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hreflang attribute


Example

Example

Display the language of the linked document:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<link id="link1" href="domoarigato.htm.html" hreflang="ja">
<script>
function displayResult(){
    var x=document.getElementById("link1").hreflang;
    alert(x);
}
</script>
</head>
<body>

<button type="button" onclick="displayResult()">Display the language of the linked document</button>

</body>
</html>

Try it »


Link 对象参考手册Link Object Other Extensions