有图片a.jpg,b.jpg,我希望在页面的某个区域循环显示2图片,如何实现?
试了以下代码,不成功!
<script language="javascript">
var the_count = 0;
var the_timeout;
ase=new Array();
ase[0]="file:///H|/piclib/a.jpg";
ase[1]="file:///H|/piclib/b.jpg";
var i=0;
function doTimer()
{
if(i==1){i=0;window.open(ase[0],"_blank")}
else {i=1;window.open(ase[1],"_self");}
the_timeout = setTimeout("doTimer();",3000);
}
</script>
</head>
<body onlosd="doTimer()">
<table width="100%" border="0" cellspacing="1">
<tr>
</tr>
</table>
</body>
</html>
显示第一张图片后
IE地址栏显示
file:///H|/a.jpg
停止循环了!!!!!
------解决方案--------------------
- HTML code
<script language="javascript"> var the_timeout; ase=new Array(); ase[0]="file:///H|/piclib/a.jpg"; ase[1]="file:///H|/piclib/b.jpg"; var i=0; function doTimer() { document.getElementById("img").src = ase[i]; if(i==1) i=0; else i=1; if(!the_timeout) clearTimeout(the_timeout); the_timeout = setTimeout("doTimer();",3000); } </script> </head> <body onload="doTimer()"> <table width="100%" border="0" cellspacing="1"> <tr> <img src="" id="img"> </tr> </table> </body> </html>