在控制台中抑制 Chrome 的“无法加载资源"消息 [英] Suppress Chrome 'Failed to load resource' messages in console
问题描述
我正在编写一个脚本,它使用 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 的“无法加载资源"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!