I need to navigate (redirect the URL automatically) to a new page when an error is encountered. I tried this in test.js
script:
var target = "<all_urls>";
function logError(responseDetails) {
errorTab=responseDetails.tabId;
console.log("response tab: "+errorTab);
//direct to the extension's error page
browser.tabs.update(errorTab,{url: "data/mypage.html"});
}//end function
browser.webRequest.onErrorOccurred.addListener(
logError,
{urls: [target],
types: ["main_frame"]}
);
Here is the manifest file:
{
"manifest_version": 2,
"name": "test",
"version": "1.0",
"description": "Adds a red border to all webpages matching mozilla.org.",
"background": {
"scripts": ["test.js"]
},
"permissions": [
"<all_urls>",
"activeTab",
"tabs",
"storage",
"webRequest"
]
}
But, nothing happens when an error is encountered. I need to redirect the error page in such away that the user can not ntoice the redirection and get the extension’s error page directly instead of having two error pages. Is this ever possible?