0

This code is working earlier. but now days its not working. may be due to chrome new version. please suggest me some working code.

<html>
  <head>
   <script src="http://code.jquery.com/jquery-2.1.0.min.js" type="text/javascript"></script>
   <script type="text/javascript">

$(document).ready(function(e) {
    $("#test").click(function(e) {
        var a = document.createElement("a");
        a.href = "http://www.google.com/";
        var evt = document.createEvent("MouseEvents");
        //the tenth parameter of initMouseEvent sets ctrl key
        evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);
        a.dispatchEvent(evt);   
    });

}); 
   </script>
  </head>
  <body>
        Google
        <a id="test" href="http://www.stupidcodes.com" target="_blank" >Open Google</a>
  </body>
</html>
Atul T
  • 1
  • 2

0 Answers0