获取鼠标位置的javascript(zz)
2008-12-19 19:30
357 查看
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;
}
};
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;
}
};
相关文章推荐
- JavaScript 获取鼠标及元素在页面上的位置
- 【javascript】事件获取鼠标相对于父容器的位置
- javascript之获取鼠标在盒子中的位置
- javascript获取鼠标位置
- Javascript 获取鼠标当前的位置实现方法
- javascript 获取鼠标的位置
- 用 javascript 获取当页面上鼠标(光标)位置 和 触发事件的对象 的方法
- JavaScript 获取鼠标点击位置坐标
- 用 javascript 获取当页面上鼠标(光标)位置
- 用 javascript 获取当页面上鼠标(光标)位置
- javascript获取鼠标当前位置坐标 详细出处参考:http://www.jb51.net/article/27204.htm
- 用javascript获取鼠标坐标位置
- javascript获取鼠标位置部分的实例代码(兼容IE,FF)
- Javascript在Firefox下获取鼠标位置
- JavaScript中几种获取鼠标点击坐标位置的方法
- 通过 JavaScript 获取页面上的鼠标位置
- JavaScript 获取鼠标点击位置坐标
- 基于JavaScript获取鼠标位置的各种方法
- javascript获取鼠标位置部分的实例代码(兼容IE,FF)
- JavaScript 获取鼠标点击位置坐标