1 <html> 2 <head> 3 <script> 4 function clickLink() 5 { 6 var evt = document.createEvent("MouseEvent"); 7 evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 8 var link = document.querySelector('a'); 9 link.dispatchEvent(evt); 10 } 11 </script> 12 </head> 13 <body> 14 <a href="#anchor">Link to anchor</a><br> 15 In between.<br> 16 <span id="anchor">Anchor</span><br> 17 After the anchor.<br> 18 </body> 19 </html> 20