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 and keyboard click events and automatically jumps to the page_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:35:372138browse

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++;
 };
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn