<div onclick='change()' id='abc'></div><script>function change(){if(localStorage.a==null){localStorage.a=0;}if(localStorage.a==5){//最多显示4张图片localStorage.a=0;//自动归零}document.getElementById("abc").innerHTML="<img src='./"+localStorage.a+".jpg'>";a=localStorage.a;localStorage.a=parseInt(a)+1;//更换图片}setInterval("change()",秒*1000);//自动更换图片,可有可无</script>
<img id="imgflag" src="images/1.gif" onclick="changeImage()">function changeImage(){ document.getElementById("imgflag").src="2.gif";}//你可以带个参数给changeImage,参数就是要更换的图片的路径。