Calling href from anchor element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Calling href from anchor element

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script language="Javascript" type="text/javascript">
        function somescript() {/*from   www.  ja  va  2 s  . c  o  m*/
            window.location.href = document.getElementById('ololo').href;
        }
    
      </script> 
      <a href="javascript:console.log('test');" id="ololo">test</a> 
      <br> 
      <a href="javascript:somescript()">click me</a>  
   </body>
</html>

Related Tutorials