如何从 XUL 访问窗口对象?
我正在尝试从 Firefox 扩展程序将 onLoad
事件设置到当前网页。我正在使用 gBrowser
对象,但我不确定这是否是最好的方法。我想为网页窗口设置一个 onLoad
事件,以便在页面加载后立即执行插件的某些操作。
提前致谢。
I'm trying to set an onLoad
event to the current web page from a firefox extension. I'm using the gBrowser
object but I'm not sure if this is the best way. I would like to set an onLoad
event to the web page window to execute some actions of the plugin as soon as the page is loaded.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过多次尝试,我找到了解决方案。假设我们有一个名为
pageLoaded
的函数
,这是我们在网站完全加载后要调用的函数。现在,我们必须向gBrowser
对象添加一个事件监听器来捕获load
事件。这里是代码:
我建议在将扩展文档添加到 gBrowser 之前使用向扩展文档添加事件侦听器。结果将是这样的:
我希望这个解决方案对某人有用。
感谢您的阅读。
After several attempts I found a solution for this. Lets say we have a
function
calledpageLoaded
, which is the one we want to call when the website has been totally loaded. Now, we have to add an event listener to thegBrowser
object to catch theload
event.Here the code:
I recommend to use add an event listener to the extension document before to add it to the gBrowser. The result would be something like this:
I hope this solution will be useful for someone.
Thanks for reading.