img 标签内如何在src中引用变量

<html>
<head>
<script language="javascript">
var adres="https://offlintab.firefoxchina.cn/static/img/search/baidu_web.png";
function imgUrl() {
        document.images.imgInit.src = adres;
    }
</script>
</head>
<body>

<img id="imgInit"  src="乱设置一个就行" onerror="imgUrl()" style="width:50px;height:25px;display:block;" />

</body>
</html>

posted @ 2019-02-22 16:23  那就墨丘利  阅读(5613)  评论(0编辑  收藏  举报