Javascript examples for Browser Object Model:Location
Convert location.href URL to Anchor link
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww . j a v a2s . co m document.getElementById("myAnchor").setAttribute("href", window.location.href); var loc = document.getElementById("myAnchor").getAttribute("href"); var t = document.createTextNode(loc); document.getElementById("myAnchor").appendChild(t); } </script> </head> <body> <a href="http://java2s.com/" id="myAnchor"></a> </body> </html>