浏览器检查器如何知道图像或其他资源是否属于加载失败的css或js文件? [英] Browser Inspector how to know if image or other resources belongs to which css or js file that was failed to load?

查看:175
本文介绍了浏览器检查器如何知道图像或其他资源是否属于加载失败的css或js文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在网页中看到一些未加载的图像,原因是css或js文件中的路径错误,但是如何知道哪个js或css文件正在尝试加载该资源。我在浏览器的检查器中进行了太多尝试,以找到某种方法,但是我无法弄清楚,因此必须在每个js和CSS文件中搜索资源名称。有什么方法可以知道尝试加载失败资源的确切js或css文件。
谢谢

解决方案

Firefox和Chrome DevTools提供了一种方法来查看启动其资源请求的方式网络面板。



Chrome开发工具



Chrome的DevTools中的 Network 面板可提供有关



它甚至允许您



不幸的是,由于JavaScript以外的原因,它还没有提供太多有用的信息或到源文件的链接(自Firefox 55起)。因此,我已经提交了多个增强请求以改进此功能。


I can see some images in my webpage that are not loading the reason is the wrong path inside the css or js file but how to know which js or css file is trying to load that resource. I tried too much in browser's inspector to find some way but I cannot figure out so I have to search each js and css file for the resource name. Is there any way to know the exact js or css file that is trying to load the failed resource. Thanks

解决方案

The Firefox and the Chrome DevTools provide a way to see what initiated the request of a resource within their Network panels.

Chrome DevTools

The Network panel within Chrome's DevTools provides information about the origin of a request within an Initiator column. All entries except the ones saying 'Other' link to the line within the JavaScript, CSS, or document, which caused the request.
For JavaScript calls it shows the stack trace that led to the request on hover.

It even allows you to highlight the initiators and dependencies by holding down Shift and hovering entries within the list.

Firefox DevTools

The Firefox DevTools Network Monitor has a Cause column indicating if a request came from JavaScript, the document, CSS, or some other source.

For JavaScript calls it provides the stack trace within a Stack Trace side bar when selecting the entry.

Unfortunately, for causes other than JavaScript it doesn't provide much useful information or links to the source files yet (as of Firefox 55). Therefore I've filed several enhancement requests to improve this feature.

这篇关于浏览器检查器如何知道图像或其他资源是否属于加载失败的css或js文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆