Chrome扩展程序标签上的onUpdated事件

编程入门 行业动态 更新时间:2024-10-25 14:26:25
本文介绍了Chrome扩展程序标签上的onUpdated事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在构建一个chrome扩展程序,该扩展程序在每次打开新标签页并加载页面时都会得到通知,为此,我正在使用chrome.tabs.onUpdated事件.

I am building a chrome extension that should get notified every time a new tab has opened and load page, and for that purpose I'am using chrome.tabs.onUpdated event.

问题是,如果在某个域(具有src)上托管的页面/标签上插入了iframe,则会触发onUpdated事件.有没有办法将这些实际"标签加载事件与为iframe加载触发的事件区分开来?

The problem is that in case an iframe is inserted on that page/tab that is hosted on some domain(has src), onUpdated event is trigered. Is there a way to differentiate these events for "real" tab load from those triggered for iframe load?

推荐答案

tabs.onUpdated在状态在loading到complete之间变化时触发.大概是,插入iframe会使标签页再次变为loading状态.

tabs.onUpdated triggers when state changes between loading to complete. Presumably, inserting an iframe puts the tab to loading state again.

您可以查看是否在onUpdated侦听器中定义了details.url-如果未定义,则您知道文档的URL并未更改.

You could see if details.url is defined in onUpdated listener - if not, you know that the document's URL did not change.

也许您应该出于目的使用 webNavigation API .在那里,您会得到一个TransitionQualifier,可用于过滤子帧导航.

Perhaps you should use webNavigation API instead for your purpose. There, you get a TransitionQualifier that you can use to filter out subframe navigation.

更多推荐

Chrome扩展程序标签上的onUpdated事件

本文发布于:2023-11-11 18:41:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   标签   程序   Chrome   onUpdated

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!