获取鼠标位置的javascript(zz)
var Mouse = new function(){
this.x = 0;
this.y = 0;
this.capture = function(evt){
if (document.all) {// IE
Mouse.x = window.event.x + document.body.scrollLeft;
Mouse.y = window.event.y + document.body.scrollTop;
} else if (document.layers||document.getElementById) { // Netscape
Mouse.x = evt.pageX;
Mouse.y = evt.pageY;
}
//alert(Mouse.x + "/" + Mouse.y); //test
};
if (document.layers) { //netscape
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = this.capture;
};
var Screen = new function(){
if (document.layers||document.getElementById) { // Netscape
this.width = window.innerWidth+window.pageXOffset;
this.height = window.innerHeight+window.pageYOffset;
} else if (document.all) {// IE
this.width = document.body.clientWidth+document.body.scrollLeft;
this.height = document.body.clientHeight+document.body.scrollTop;
}
};