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
Add a ment  | 

2 Answers 2

Reset to default 8

Use 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