如何判斷圖片地址是否失效
更新時(shí)間:2007年02月02日 00:00:00 作者:
<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="圖片來源錯(cuò)誤";
}
}
</script>
<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="圖片來源錯(cuò)誤";
}
}
</script>
相關(guān)文章
js 獲取站點(diǎn)應(yīng)用名的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)硪黄猨s 獲取站點(diǎn)應(yīng)用名的簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-08-08js 采用delete實(shí)現(xiàn)繼承示例代碼
這篇文章主要介紹了js如何采用delete實(shí)現(xiàn)所謂的繼承,下面有個(gè)不錯(cuò)的示例,大家可以參考下2014-05-05js+css實(shí)現(xiàn)三級(jí)導(dǎo)航菜單
這篇文章主要為大家詳細(xì)介紹了js+css實(shí)現(xiàn)三級(jí)導(dǎo)航菜單,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08