所以三天多来,我一直在寻找如何从控制台隐藏这个错误并响应这个错误:
加载资源失败:net::ERR_NAME_NOT_RESOLVED
Google Chrome 控制台中的错误图像,我想隐藏和处理
官方 chrome 文档都没有帮助。https://developers.google.com/web/tools/chrome-devtools/console/track-exceptions
也没有我在谷歌搜索中出现的任何技巧。
产生这个不可抗拒的错误发生的 JavaScript
(用于快速测试处理溶液)
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
information: <div id="information" ></div>
<script>
var httpRequest = new XMLHttpRequest();
httpRequest.open("GET", "https://sdajfkljsdfk.lt", true);
httpRequest.onload = function (e) {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
console.log(httpRequest.responseText);
} else {
document.getElementById("information").innerHTML = "Error Unresponsive Domain";
}
}
};
httpRequest.send(null);
</script>
</body>
</html>