Create a custom DNS error page

孤街醉人 提交于 2019-11-27 14:14:14

问题


I am building a new extension and I would like to customize the default error page in Google Chrome. I have gone through the "Override Pages" documentation here but have yet to find anything about customizing the page I have specified.

Any suggestions are much appreciated. Thank you.

The error page I want to customize is:

This webpage is not available

The server at ____ can't be found, because the DNS lookup failed. DNS is the network service that translates a website's name to its Internet address. This error is most often caused by having no connection to the Internet or a misconfigured network. It can also be caused by an unresponsive DNS server or a firewall preventing Google Chrome from accessing the network. Here are some suggestions: Reload this webpage later. Check your Internet connection. Restart any router, modem, or other network devices you may be using. Check your DNS settings. Contact your network administrator if you're not sure what this means. Try disabling network prediction by following these steps: Go to the wrench menu > Options > Under the Hood and deselect "Predict network actions to improve page load performance." If this does not resolve the issue, we recommend selecting this option again for improved performance. Add Google Chrome as a permitted program in your firewall's or antivirus software's settings. If it is already a permitted program, try deleting it from the list of permitted programs and adding it again. If you use a proxy server, check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server, adjust your proxy settings: Go to the wrench menu > Options > Under the Hood > Change proxy settings... > LAN Settings and deselect the "Use a proxy server for your LAN" checkbox.

Error 105 (net::ERR_NAME_NOT_RESOLVED): Unable to resolve the server's DNS address.


回答1:


The chrome.override isn't meant for this. Instead you can detect a DNS resolution error using chrome.webRequest API. If you see this error you can load a different URL into the tab. Something along these lines:

chrome.webRequest.onErrorOccurred.addListener(onErrorOccurred, {urls: ["http://*/*", "https://*/*"]});

function onErrorOccurred(details)
{
  if (details.error == "net::ERR_NAME_NOT_RESOLVED")
    chrome.tabs.update(details.tabId, {url: "..."});
}


来源:https://stackoverflow.com/questions/8514883/create-a-custom-dns-error-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!