Home > Web Front-end > JS Tutorial > body text

js monitors mouse click and keyboard click events and automatically jumps to the page_javascript skills

WBOY
Release: 2016-05-16 16:35:37
Original
2126 people have browsed it

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++;
 };
});
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!