'chrome.webNavigation.onCompleted和chrome.tabs.onUpdated.addListener与'complete'之间的区别是什么? [英] What is difference between chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with 'complete'
问题描述
chrome.webNavigation.onCompleted
和 chrome.tabs.onUpdated.addListener
与 changeinfo = complete
。
这两者之间有什么区别,哪一个可以保证页面中的everthing已经加载。我发现 chrome.tabs.onUpdated.addListener
有时甚至会在几乎没有http请求被激活时触发。
即使在导航栏中也会调用 chrome.webNavigation.onCompleted
发生在一个子帧中,而 chrome.tabs.onUpdated.addListener
只有在标签更新时才会触发,这是因为标签属性的变化,如 status
或 url
。观察传递给回调函数此处的changeInfo对象。
另外, chrome.webNavigation.onCompleted
支持过滤的事件,因此您可以指定过滤器,以便仅在过滤器通过。观看此处如何将过滤器应用于活动。
因此,如果您同时使用两个事件侦听器,您将观察到 chrome.webNavigation.onCompleted
会为单个选项卡激发很多次, chrome.tabs.onUpdated.addListener
可能只触发一次或两次(由于状态从加载完成到完成)。
我希望这有助于。
In chrome APIs there are two functions that theoretically points to the same evet.
chrome.webNavigation.onCompleted
and chrome.tabs.onUpdated.addListener
with changeinfo=complete
.
What is the difference between these two and which one guarantee that everthing in the page have loaded. I have found that chrome.tabs.onUpdated.addListener
sometimes fire even when few http requests are remaining.
The chrome.webNavigation.onCompleted
is invoked even when the navigation occurs in a subframe whereas the chrome.tabs.onUpdated.addListener
is only triggered when a tab is updated due to change in a tab's property like status
or url
. Observe the changeInfo object that is passed to the callback function here.
Also, the chrome.webNavigation.onCompleted
supports filtered events, thus you can specify the filter so that the event is triggered only when the filter is passed. Observe here how to apply filters to an event.
So, if you use both the event listeners, you will observer that the chrome.webNavigation.onCompleted
is fired many a times for a single tab whereas the chrome.tabs.onUpdated.addListener
might fire only once or twice (due to status change from loading to complete).
I hope this helps.
这篇关于'chrome.webNavigation.onCompleted和chrome.tabs.onUpdated.addListener与'complete'之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!