<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript">
function nofind() {
var img = event.srcElement;
alert("没有图片,我就默认一张");
img.src = "https://www.baidu.com/img/bd_logo1.png";// 百度图片的地址
img.onerror = null;// 控制不要一直跳动
}
</script>
</head>
<body>
<img src="/images/不存在图.jpg" alt="北京" title="北京" onerror="nofind();">
</body>
</html>
原文:https://blog.csdn.net/milijiangjun/article/details/78180025