admin管理员组文章数量:1291061
Because it isn't possible to use Greasemonkey for this, I want to write a Chrome extension that will reload a page if it initially failed to load.
I know how to write a Chrome extension, I've already injected scripts and figured out how to municate with pages, so I have basic knowledge of how tabs work and how to build my manifest.
What events am I looking for and how can I make it work for both GET and POST requests?
Because it isn't possible to use Greasemonkey for this, I want to write a Chrome extension that will reload a page if it initially failed to load.
I know how to write a Chrome extension, I've already injected scripts and figured out how to municate with pages, so I have basic knowledge of how tabs work and how to build my manifest.
What events am I looking for and how can I make it work for both GET and POST requests?
Share Improve this question edited May 23, 2017 at 11:58 CommunityBot 11 silver badge asked May 18, 2014 at 17:12 f.ardelianf.ardelian 6,9568 gold badges40 silver badges54 bronze badges 3- 1 Would be great if you let us be part of your solution ;-) I'm looking for the same solution. Do you implemented this hack in a plugin? – Smoki Commented Apr 25, 2016 at 11:49
- @Smoki Sorry, but this was a long time ago and I don't have the code any more. – f.ardelian Commented Apr 30, 2016 at 11:36
- @Smoki if you're looking for a Chrome extension that will continually retry loading a page that has failed to load, I just posted an answer with such an extension: stackoverflow./a/66238031/3442232 – Andrew D. Bond Commented Feb 17, 2021 at 8:24
2 Answers
Reset to default 8Use chrome.webNavigation.onErrorOccurred
or chrome.webRequest.onErrorOccurred
to detect navigation errors. These APIs cannot be used in a content script, so you have to add a background page or event page to your extension.
I remend to use the webNavigation
API because these can also be used with event pages (unlike the webRequest
API). Here is an example, use chrome.tabs.reload
instead of chrome.tabs.update
to get what you want.
For others looking for a Chrome extension that will continually retry loading a page that has failed to load, the Error Page Enhanced Chrome extension has this as part of its primary functionality.
本文标签: javascriptChrome extension to reload page on load errorStack Overflow
版权声明:本文标题:javascript - Chrome extension to reload page on load error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741517949a2383007.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论