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>javascript

相關文章
相關標籤/搜索