Change Chrome 4xx Page Change Chrome 4xx Page google-chrome google-chrome

Change Chrome 4xx Page


You can customize the error page with webNavigation API. Add an event Listener for onErrorOccurred event and update relevant details.

Check sample code as a reference.

Demonstration

manifest.json

Registered background page and added all relevant permissions to manifest file.

{    "name": "Customize error page",    "description": "",    "version": "1",    "manifest_version": 2,    "background": {        "scripts": [            "background.js"        ]    },    "permissions": [        "webNavigation",        "<all_urls>"    ],    "web_accessible_resources": [        "page.html"    ]}

background.js

Redirected to our custom Page in case of any error, you can customize this to desired level.

//Adding a Listener to Error Occured Eventchrome.webNavigation.onErrorOccurred.addListener(function (details) {    // Updating the browser window with desired URL    chrome.tabs.update(details.tabId, {        url: chrome.extension.getURL("page.html")    });});

page.html

Some trivial code

<html>    <style>        body {            background:yellow;            position:absolute;        }    </style>    <body>        <div style="top: 200px;position: absolute;left: 500px;width: 500;font-size: 40px;">This is a Nice Description</div>    </body></html>

Reference


Go to options, privacy settings, and uncheck the box:

"Use a web service to help resolve navigation errors"

Detailed instructions here.