当“onload”发生时我如何得到通知脚本已完成
当 html 页面加载时我收到通知
-> onStateChange, stateFlags: STATE_IS_NETWORK + STATE_STOP
但当页面加载并且 onload 脚本完成运行时我需要通知。
有什么提示吗? 谢谢
I get a notification when a html page is loaded
-> onStateChange, stateFlags: STATE_IS_NETWORK + STATE_STOP
but I need a notification when the page ist loaded and a onload script has finished running.
Any hints ?
THX
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以添加第二个侦听器来“加载”事件。我无法找到任何文档来确认事件侦听器是按设置顺序调用的,但下面代码的一些实验表明情况似乎如此。如果存在竞争条件,我希望有时会看到“AB”,有时会看到“BA”:
需要注意的一件事是,如果您太晚添加第二个事件侦听器(即加载事件已经触发),它将不会称为。
不管怎样,感觉像是一个黑客,但只是一个想法,以防你找不到更好的方法来处理它。
Maybe you could add a second listener to "load" events. I was not able to find any documentation confirming that events listeners are called in order they are set, but some experiments with the code below shows that it seems to be the case. If there was a race condition I would expect to see sometimes "AB" and sometimes "BA":
One thing to be careful with this is that if you add the second event listener too late (i.e. the load event already fired) it will not be called.
Anyway, feels like a hack, but is just an idea in case you cannot find a better way to handle it.
您可以使用:
但请记住 gBrowser 引用选项卡的内容,因此这将在选择每个选项卡时检查它
You could use:
but remember that gBrowser refers to the content of a tab so this will check every tab when it has been selected