碰到图片无法显示自动隐藏

<img src="1.gif" onerror="doHide(this)" onload="this.style.display='inline'" width=348 height=446>
<script>
function doHide(e){
	alert(1);
	e.style.display = "none";
	setTimeout(function(){e.src = "1.gif?tmp="+Math.random();}, 4000);
}
</script>

使用这段代码可以让图片在出错的时候隐藏

你可能感兴趣的:(html)