document.elementFromPoint(x,y);不工作
我正在使用
document.elementFromPoint(x,y);
函数来找出鼠标单击时的底层元素。当我用firefox打开相应的html文件时,它工作正常。但我已经编写了一个使用 gtkmozembed 来打开 html 文件的应用程序。当我使用应用程序打开 html 文件并单击页面时,出现以下错误:
TypeError: document.elementFromPoint is not a function
为什么会这样?实际上所有适用于 Firefox 的功能也适用于 gtkmozembed 对吗?(因为 Firefox 和 gtkmozembed 内部都使用 Gecko 引擎)
i am using
document.elementFromPoint(x,y);
function to find out the underlying element on the mouse click. It is working fine when i open the corresponding html file with firefox. But i have written an application using gtkmozembed to open html files. When i open html file with my application and clicked on the page it is giving following error:
TypeError: document.elementFromPoint is not a function
Why it is so? Actually all the functions which works for firefox, also work with gtkmozembed right?(as both firefox and gtkmozembed uses gecko engine internally)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Firefox 和 gtkmozembed 确实都使用 Gecko 渲染引擎,但您尝试代码的引擎版本可能不同,因此该功能可能可用也可能不可用。
值得注意的是,在现实中几乎没有必要使用这个函数 - 您可以从另一面解决问题 - 检查 event.target 属性以查看鼠标事件的起源。
顺便说一句:document.elementFromPoint 函数是源自 Internet Explorer 的伟大且专有技术的另一个示例。与许多其他好的功能一样,它最近才被包括 Mozilla 在内的许多供应商采用并实施。
It is true both Firefox and gtkmozembed use Gecko rendering engine, but versions of engines you are trying your code in may be different, so that the function may be or may be not available.
Worth noticing, it is hardly necessary to use this function in reality - you can approach the problem from the other side - check the event.target property to see where your mouse event was originated.
BTW: document.elementFromPoint function is another example of great yet proprietary technology originated from Internet Explorer. As many other good features it was picked up only recently and implemented by many vendors including Mozilla.