在控制台中抑制 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 的“加载资源失败"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)