Set <a> href value - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Set <a> href value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from   w w w  . j  a  va2  s . c o m
var SiteURL = '';
SiteURL = 'http://java2s.com';
document.getElementById("a").href=SiteURL;
    }

      </script> 
   </head> 
   <body> 
      <a href="linkofuser" id="a" >test</a>  
   </body>
</html>

Related Tutorials