如果在firefox下获得鼠标坐标??

surfchen 2005-03-18 02:31:45
如果在firefox下获得鼠标坐标??
以下代码为何无法获得??
<script type="text/javascript">
<!--
function alertX()
{
alert(window.screenX)
}
-->
</script>
<div onMouseOver="alertX()">getX</div>
...全文
500 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
ice_berg16 2005-03-24
  • 打赏
  • 举报
回复
e = e || window.event
=>
e = e ? e : window.event;

你看下fason这篇
http://community.csdn.net/Expert/topic/3673/3673363.xml?temp=.9517328
surfchen 2005-03-23
  • 打赏
  • 举报
回复
up
ice_berg16 2005-03-23
  • 打赏
  • 举报
回复
firefox下的事件驱动和IE下有所区别
事件函数必须传递事件,你这个函数在IE下也是通不过的,screenX不是window对象的属性,是event的
<script type="text/javascript">
<!--
function alertX(e)
{
e = e || window.event;
alert(e.screenX)
}
-->
</script>
<div onMouseOver="alertX(event)">getX</div>
surfchen 2005-03-23
  • 打赏
  • 举报
回复
e = e || window.event;这种的用法是什么意思呢?

有没有详细解说ie和firefox事件驱动的文章?我想认真看看.
chaobill 2005-03-21
  • 打赏
  • 举报
回复
DOM Event Reference

clientX Returns the horizontal position of the event.
clientY Returns the vertical position of the event.

http://www.mozilla.org/docs/dom/domref/
http://www.mozilla.org/docs/dom/domref.zip

做Firefox必看
surfchen 2005-03-21
  • 打赏
  • 举报
回复
firefox里的clientX和IE下的好象有不同~~~~包括获得该属性~~~

如果我要在某个元素里触发获得鼠标事件,在firefox 下,脚本是不是必须包含这样的语句块??

document.getElementById(id).event

之前我看到过一个在body 元素下通过mouseover获得鼠标坐标的代码段~~兼容IE和firefox
但是我想用在非body 元素下却始终不成功~~


各位前辈高人都说说话吧~~~郁闷死了~~想兼容一下IE和FF,真是难~~ 偶对DOM又比较生疏...
surfchen 2005-03-21
  • 打赏
  • 举报
回复
up
surfchen 2005-03-20
  • 打赏
  • 举报
回复
up
surfchen 2005-03-19
  • 打赏
  • 举报
回复
UP
surfchen 2005-03-19
  • 打赏
  • 举报
回复
行的吧??我好象以前看过有人贴过一段能获得firefox下鼠标坐标的代码了
cybernaute 2005-03-19
  • 打赏
  • 举报
回复
firefox 好象不行的
ie下的也是event.clientX
surfchen 2005-03-19
  • 打赏
  • 举报
回复
UP
surfchen 2005-03-18
  • 打赏
  • 举报
回复
本帖所有的“果”改为“何”

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧