检测破碎的CSS“背景图像”在JavaScript / jQuery中 [英] Detecting Broken CSS "background-images" in JavaScript/jQuery
本文介绍了检测破碎的CSS“背景图像”在JavaScript / jQuery中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是检测损坏图像的示例
http://maisonbisson.com/blog/post/12150/detecting-broken-images-in-javascript/
Here is an example to detect broken Images
http://maisonbisson.com/blog/post/12150/detecting-broken-images-in-javascript/
但是有可能检测出破碎的背景图像吗?
例如:
but is it possible to detect an broken background-image?
For exmaple:
<div style="background-image:url('http://myimage.de/image.png');"></div>
推荐答案
您是否可以控制未找到404您服务器上的页面?在这种情况下,您可以将其指向一个脚本,该脚本在请求的URL中查找.jpg / .png / .gif并相应地记录,然后向用户输出404页面。
Do you have control over the "404 not found" page on your server? In that case you could point it to a script that looks for .jpg/.png/.gif in the requested URL and log accordingly, then outputting a 404 page to the user.
这篇关于检测破碎的CSS“背景图像”在JavaScript / jQuery中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文