发布于 3年前

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

<body>   
<IMG src="http://www.aaa.com/logos/Logo\_25wht.gif" alt="图片来源正常"></p>   
<IMG src="abc.gif">   
</body>   
<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.edoou.com/blog/logo.gif";   
             this.alt="图片来源错误";   
         }   
    }   
</script>
©2020 edoou.com   京ICP备16001874号-3