问题解决方法:
修改代码setInterval(fun(),3000);为setInterval(fun,3000);
正确代码
<body>
<img id="img" src="img/banner_1.jpg" width="100%">
<input type="button" id="back" value="后退">
<script>
var number = 1;
function fun(){
number ++ ;
if(number > 3){
number = 1;
}
var img = document.getElementById("img");
img.src = "img/banner_"+number+".jpg";
}
setInterval(fun,3000);
var back = document.getElementById("back");
back.onclick = function(){
history.go(-1);
}
</script>
</body>