在控制台中抑制 Chrome 的“加载资源失败"消息

Suppress Chrome #39;Failed to load resource#39; messages in console(在控制台中抑制 Chrome 的“加载资源失败消息)

本文介绍了在控制台中抑制 Chrome 的“加载资源失败"消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,它使用 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 的“加载资源失败"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在控制台中抑制 Chrome 的“加载资源失败"消息

基础教程推荐