Javascript:IE8事件坐标 [英] Javascript: IE8 event coordinates
本文介绍了Javascript:IE8事件坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎找不到在IE8中获取事件坐标的方法,它只会触发错误,如... pageX undefined,clientX undefined等。虽然它可以在其他浏览器中查找。
I can't seem to find a way to get coordinates of event in IE8, it just triggers errors like... pageX undefined, clientX undefined etc. While it works find in other browsers.
这是我想要做的:
document.onmousemove=setcoord;
function setcoord(e){
var xxcoord = e.pageX||(e.clientX+document.body.scrollLeft);
var yycoord = e.pageY||(e.clientY+document.body.scrollTop);
}
有没有解决方法来获取鼠标位置?
Is there any workaround to get that mouse position ?..
推荐答案
以下内容似乎正常。我不知道它是否是正确的方法:
The following seems to work. I'm not sure its is the proper way to do this:
var x=event.clientX;
var y=event.clientY;
这篇关于Javascript:IE8事件坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文