問題描述
我正在編寫一個腳本,它使用 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模板網!