Anchor hreflangProperty

Anchor 对象参考手册Anchor Object

Definition and Usage

The hreflang property sets or returns the value of the hreflang attribute in a link.

The hreflang property sets or returns the language code of the linked resource.

Syntax

Set the hreflang property:

anchorObject.hreflang="languagecode"

Return the hreflang property:

anchorObject.hreflang

Value Description
languagecode The language code of the linked resource


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hreflang attribute.


Example

Example

Return the language code of the linked resource:

<a id="example" hreflang="zh-cn" href="//www.example.com/">Example</a><br> <script>document.write("The hreflang of the link: "); document.write(document.getElementById('example').hreflang);</script>

The output of the above example is:

zh-cn

Try it Yourself »


Anchor 对象参考手册Anchor Object Other Extensions