Event click handler on href <a> tag - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor


Event click handler on href <a> tag

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    function doWork(){/*from  ww  w. j a v a  2 s.  com*/
          //... do your works
          return true; // then return true to redirect

      <a href="http://www.google.com" target="_new" onclick="return doWork();">Click to redirect</a>  

Related Tutorials