Home > Article > Web Front-end > js monitors mouse click and keyboard click events and automatically jumps to the page_javascript skills
js monitors mouse click (onmousedown) and keyboard click (onkeydown) events and automatically jumps to the page. Friends who are learning can refer to it
$(function(){ var i = 0; document.onmousedown=function(event){ if(i==1){ window.open('http://www.njxblog.com'); } //setTimeout(function (){window.open('http://www.jb51.net')},2000); //定时不太好使,会被浏览器当成广告的 i++; }; var j = 0; document.onkeydown=function(event){ if(j==1){ window.open('http://www.njxblog.com'); } //setTimeout(function (){window.open('http://www.jb51.net')},2000); //定时不太好使,会被浏览器当成广告的 j++; }; });