Chrome扩展程序未在后退按钮上运行 [英] Chrome extension not running on back button

查看:79
本文介绍了Chrome扩展程序未在后退按钮上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Chrome扩展程序,每次加载某些网页时都需要运行。

I am writing a chrome extension that needs to run every time certain webpages are loaded.

目前,当我第一次加载页面时,脚本会运行。但是,如果我然后转到另一个页面并单击返回以使其返回到原始页面,则脚本不会运行。如果我然后刷新页面它会运行脚本。

Currently when I first load a page the script runs. However if I then go to another page and click "Back" so it returns to the original page, the script does not run. If I then refresh the page it does run the script.

我怀疑这与chrome没有运行扩展有关,如果它正在加载页面的缓存版本? (可能是完全垃圾)。

I suspect this is something to do with chrome not running extensions if it is loading a cached version of the page? (Might be total rubbish).

目前清单文件说run_atdocument_end。

Currently the manifest file says to "run_at" "document_end".

任何人都有任何线索,即使我通过导航返回打开页面,我怎么能让它运行脚本?

Anyone have any clue how I can make it run the script even when I open the page by navigating "Back"?

推荐答案

这个确实是缓存窗口内容的问题。如果您的Chrome扩展程序是永久监控的,您可以尝试在网址更改时触发,而不是在加载时触发。虽然这可能不是最好的做法,但有点变通方法。

This is indeed an issue with the cached window content. If your Chrome extension is permanently monitoring, you could try to trigger it on URL change, rather than on load. Although this might not be the best practice, and a bit a workaround.

这篇关于Chrome扩展程序未在后退按钮上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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