Javascript 检查文件是否存在但防止控制台中出现 404 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7035466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check if file exists but prevent 404 error in console from showing up
提问by Muers
Is it possible to check to see if a file/page exists via JavaScript but prevent the 404 Error from showing up in the console?
是否可以通过 JavaScript 检查文件/页面是否存在,但防止 404 错误显示在控制台中?
采纳答案by Muers
Seems like the answer is: No. Can't avoid getting a 404 error in the console unless you kick off a call to a server-side script to check file existence.
似乎答案是:否。除非您启动对服务器端脚本的调用以检查文件存在,否则无法避免在控制台中出现 404 错误。