如何判断图片地址是否失效
如何判断图片地址是否失效
发布时间:2016-12-30 来源:查字典编辑
摘要:varAllImages=document.getElementsByTagName("IMG");for(i=0;i

<html>

<body>

<IMGsrc="http://www.google.com/logos/Logo_25wht.gif"alt="图片来源正常"></p>

<IMGsrc="abc.gif">

</body>

</html>

<scriptlanguage="javascript">

varAllImages=document.getElementsByTagName("IMG");

for(i=0;i<AllImages.length;i++)

{

varimg=AllImages[i];

img.onerror=function()

{

this.src="http://www.yaosansi.com/blog/logo.gif";

this.alt="图片来源错误";

}

}

</script>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类