var mouseX = null;
var mouseY = null;
var TimeoutID = null;
function
mouseover(e){
e = e || window.event;
mouseX = parseInt(e.clientX - window.innerWidth/2);
mouseY = parseInt(e.clientY - window.innerHeight/2);
TimeoutID = window.setTimeout(AutoMove,0);
}
function MouseOut(e){
mouseX = null;
mouseY = null;
if(
TimerID)
window.clearTimeout(TimerID);
TimerID = null;
}
function AutoMove(){
if(!mouseX) return;
if(mouseX >0 || mouseY <0){
function B(){};
B();//想要效果这个必须加!
}else {
function A(){};
A();//想要效果这个必须加!
}
mouseX = null;
mouseY = null;
}
document.addEventListener("mouseover",
MouseOver,false);
document.addEventListener('mouseout',MouseOut,false);
益出不益出不太清楚,但是就字面错误就已经有2个了(红色体)。而且不支持IE浏览器!