我正在尝试打开一个文档,window.open()
其中抛出
HTTP 错误 404.3
现在我知道在 web.config 中使用IIS Settings
或设置的解决方案staticContent
。但我只想在出现 404.3 错误时显示警报。
我找到了另一个对我有用的解决方案。
var XMLHttp = new XMLHttpRequest();
XMLHttp.open("GET", "" + url + "");
XMLHttp.onreadystatechange = handlerFunction;
XMLHttp.send(null);
function handlerFunction() {
if (XMLHttp.readyState == 4 && XMLHttp.status == 404) {
alert("File not reachable");
}
else if (XMLHttp.readyState == 4 && XMLHttp.status !== 404) {
window.open(url, '_blank');
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句