js實現圖片不能顯示時替換圖片顯示

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>替換示例</title>
</head>

<body>
<img id="img" src="001.jpg" onerror="showerrimg(this);" >
<script language="JavaScript">
function showerrimg(obj){
     var errorimg = "error.jpg";//替換圖片地址
     obj.src = errorimg;
}
</script>
</body>
</html>
相關文章
相關標籤/搜索