从 nsIDOMEvent 获取 URI
我正在使用 XPCOM,并且想要获取用户单击的页面部分的 URI(例如,用户右键单击框架,并且我想要显示该框架的 URL)。 因此,我设置了一个鼠标侦听器 (nsIDOMEventListener),然后当发生单击时,handleEvent 回调使我可以访问 nsIDOMEvent。
我的问题是,如何从 nsIDOMEvent 获取 URI?
I'm using XPCOM, and I want to get the URI of the portion of a page the user clicks (e.g., a user right-clicks on a frame, and I want to display the URL of that frame). So I've set up a mouse listener (nsIDOMEventListener) and then when a click occurs, the handleEvent callback gives me access to the nsIDOMEvent.
My question is, how do I get the URI from the nsIDOMEvent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:
在事件上,调用 getTarget().queyInterface(NS_IDOMHTMLELEMENT_IID).getOwnerDocument()。
queryInterface(NS_IDOMHTMLDOCUMENT_IID).getURL()
(上面是伪代码。您必须根据您使用的语言进行调整)
To answer my own question:
on the event, call getTarget().queyInterface(NS_IDOMHTMLELEMENT_IID).getOwnerDocument().
queryInterface(NS_IDOMHTMLDOCUMENT_IID).getURL()
(The above is pseudo-code. You'll have to adapt it depending on the language you're using)