Change Chrome 4xx Page

前端 未结 2 1156
离开以前
离开以前 2021-01-05 17:55

I\'m deploying a kiosk system that uses Chrome to display a java web app running in jetty started with a windows service wrapper. It takes some time after the system starts

相关标签:
2条回答
  • 2021-01-05 18:43

    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 Event
    chrome.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

    • webNavigation.onErrorOccurred
    0 讨论(0)
  • 2021-01-05 18:46

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

    "Use a web service to help resolve navigation errors"

    Detailed instructions here.

    0 讨论(0)
提交回复
热议问题