我正在编写一个脚本,它使用 XMLHttpRequest 来搜索由相对路径定义的文件,通过尝试将该相对路径与脚本知道的其他相同域绝对路径进行解析,然后尝试加载该文件从那个解析的网址.如果遇到 404,我只是尝试将文件相对路径解析为另一个绝对路径,然后重试.对于这个特定的脚本,遇到 404 完全没问题 - 但是,我的控制台到处都是加载资源失败:服务器响应状态为 404(未找到)消息,我想禁止它们.
据我所知,没有要捕获的错误——错误情况由 xmlHttpRequest.onreadystatechange 处理程序处理,并且没有 window.onerror.
有没有办法抑制这些消息?
谢谢
引入了这个功能 和其他设置.
I'm writing a script that uses an XMLHttpRequest to search for a file defined by a relative path, by attempting to resolve that relative path against other same domain absolute paths that the script is aware of, then attempting to load the file from that resolved url. If I encounter a 404, I just try to resolve the files relative path against another absolute path, and try again. For this particular script, its perfectly fine to encounter a 404- however, my console is littered with 'Failed to load resource: the server responded with a status of 404 (Not Found) messages, and I want to suppress them.
There is no error to catch as far as I can see- error cases are handled by the xmlHttpRequest.onreadystatechange handler, and there is no window.onerror.
Is there any way to suppress these messages?
Thanks
This feature was introduced last year. You can enable it here: DevTools->Settings->General->Console->Hide network messages.
See also Filtering the Console output and Additional settings in the devtools documentation.
这篇关于在控制台中抑制 Chrome 的“加载资源失败"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
即使在调用 abort (jQuery) 之后,浏览器也会等待Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在调用 abort (jQuery) 之后,浏览器也会等待 ajax 调用
JavaScript innerHTML 不适用于 IE?JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不适用于 IE?)
XMLHttpRequest 无法加载,请求的资源上不存在“AXMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 无法加载,请求的资
XHR HEAD 请求是否有可能不遵循重定向 (301 302)Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 请求是否有可能不遵循重定向 (301 302))
NETWORK_ERROR:XMLHttpRequest 异常 101NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 异常 101)
XMLHttpRequest 206 部分内容XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分内容)