Js listens for mouse click and keyboard click events and automatically jumps to the page
- 2020-03-30 03:59:26
- OfStack
Js monitor mouse click (onmousedown) and keyboard click (onkeydown) events and automatically jump to the page, in the study of friends can refer to the next
$(function(){
var i = 0;
document.onmousedown=function(event){
if(i==1){
window.open('http://www.njxblog.com');
}
//setTimeout(function (){window.open('//www.jb51.net')},2000); // Timing is not good, will be browser as advertising
i++;
};
var j = 0;
document.onkeydown=function(event){
if(j==1){
window.open('http://www.njxblog.com');
}
//setTimeout(function (){window.open('//www.jb51.net')},2000); // Timing is not good, will be browser as advertising
j++;
};
});
PS: here again for you to recommend an online query tool about JS events, summed up the common JS event types and functions:
Javascript events and function description:
(link: http://tools.jb51.net/table/javascript_event)