如何判断图片地址是否失效


<html>
<body>
<IMG src="http://www.google.com/logos/Logo_25wht.gif" alt="图片来源正常"></p>
<IMG src="abc.gif">
</body>
</html>
<script language="javascript">
var AllImages=document.getElementsByTagName("IMG");
for(i=0;i<AllImages.length;i++)
{
var img=AllImages[i];
img.onerror=function()
{
this.src="http://www.yaosansi.com/blog/logo.gif";
this.alt="图片来源错误";
}
}
</script>
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3