event中几个坐标问题
/*event中几个坐标问题*/
function test()
{
alert("event.clientX="+event.clientX+"---event.clientY="+event.clientY);
alert("event.offsetX="+event.offsetX+"---event.offsetY="+event.offsetY);
alert("event.x="+event.x+"---event.y="+event.y);
alert("event.screenX="+event.screenX+"---event.screenY="+event.screenY);
}
/*
<div id="parent" style="border:1px solid #000000;width:400px;height:200px">
<div id="child" onmouseover="test()" style="border:1px solid #000000;width:200px;height:100px">
asdfasdf
</div>
</div>
event.clientX,event.clientY 指鼠标在客户端区域的x,y坐标
event.offsetX,event.offsetY 指鼠标偏离引起该事件的对象的x,y距离
event.x,event.y 鼠标相对父元素的x,y坐标
event.screenX,event.screenY 鼠标相对整个屏幕的x,y坐标
*/
function test()
{
alert("event.clientX="+event.clientX+"---event.clientY="+event.clientY);
alert("event.offsetX="+event.offsetX+"---event.offsetY="+event.offsetY);
alert("event.x="+event.x+"---event.y="+event.y);
alert("event.screenX="+event.screenX+"---event.screenY="+event.screenY);
}
/*
<div id="parent" style="border:1px solid #000000;width:400px;height:200px">
<div id="child" onmouseover="test()" style="border:1px solid #000000;width:200px;height:100px">
asdfasdf
</div>
</div>
event.clientX,event.clientY 指鼠标在客户端区域的x,y坐标
event.offsetX,event.offsetY 指鼠标偏离引起该事件的对象的x,y距离
event.x,event.y 鼠标相对父元素的x,y坐标
event.screenX,event.screenY 鼠标相对整个屏幕的x,y坐标
*/
作者:Jackhuclan
出处:http://jackhuclan.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://jackhuclan.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。