最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is difference between chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with 'com

programmeradmin2浏览0评论

In chrome APIs there are two functions that theoretically points to the same evet.

chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with changeinfo=plete.

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.

In chrome APIs there are two functions that theoretically points to the same evet.

chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with changeinfo=plete.

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.

Share Improve this question edited Jan 31, 2016 at 23:20 Konrad Dzwinel 37.9k12 gold badges102 silver badges106 bronze badges asked Jan 27, 2016 at 7:00 CryptoKittyCryptoKitty 7355 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

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 plete).

I hope this helps.

发布评论

评论列表(0)

  1. 暂无评论