Convert location.href URL to Anchor link - Javascript Browser Object Model

Javascript examples for Browser Object Model:Location


Convert location.href URL to Anchor link

Demo Code

ResultView the demo in separate window

      <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);


      <a href="" id="myAnchor"></a>  

Related Tutorials