在onload事件触发后再用脚本改图片地址
<script type="application/javascript">
document.addEventListener('DOMContentLoaded',function(){
var images=[
'image1.png',
'image2.png'
// ...
];
document.getElementById('imgid').setAttribute('src',
images[Math.round(Math.random()*(images.length-1))]);
},false)
</script>
在这个js里images是一个图片地址的数组,用math.random随机选择一个图片显示
imgid是你img标签的id属性的值
温馨提示:答案为网友推荐,仅供参考