'chrome.webNavigation.onCompleted和chrome.tabs.onUpdated.addListener与'complete'之间的区别是什么? [英] What is difference between chrome.webNavigation.onCompleted and chrome.tabs.onUpdated.addListener with 'complete'

查看:752
本文介绍了'chrome.webNavigation.onCompleted和chrome.tabs.onUpdated.addListener与'complete'之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome API中,有两个函数理论上指向相同的evet。



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆