Javascript examples for DOM HTML Element:Link
The href property sets or gets the URL of a linked document.
Set the href property with the following Values
Value | Description |
---|---|
URL | Sets the URL of the linked resource/document |
A String, representing the URL of the linked document.
The following code shows how to return the URL of the linked document:
<!DOCTYPE html> <html> <head> <link id="myLink" href="http://java2s.com" hreflang="ja"> </head>/*ww w. j a va 2s. c o m*/ <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myLink").hreflang = "en-us"; document.getElementById("demo").innerHTML = "The language code was changed from 'ja' to 'en-us'."; } </script> </body> </html>