Opening a link via javascript code - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Opening a link via javascript code

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function f1() {//from w  w  w .j av  a  2s. c  o m
    window.open(document.getElementById("a1").href, "_blank");
}

      </script> 
   </head> 
   <body> 
      <a id="a1" href="https://www.java2s.com/"> </a> 
      <input type="button" onclick="f1();return false;">  
   </body>
</html>

Related Tutorials