利用window.setInterval("loadpic()",1000)使图片自动切换,一共四张图.但没效果.并不切换.错在哪里?谢谢function loadpic()
{
var pic=document.getElementById("im");
pic.src="tpxw/"+pic_path_array[pic_count];
pic.width="165";
pic.height="143";
var tb=document.getElementById("contain");
tb.rows[2][0].innerText=pic_title_array[pic_count];
pic_count=pic_count+1;
if (pic_count==4)
{
pic_count=0;
}
}
{
var pic=document.getElementById("im");
pic.src="tpxw/"+pic_path_array[pic_count];
pic.width="165";
pic.height="143";
var tb=document.getElementById("contain");
tb.rows[2][0].innerText=pic_title_array[pic_count];
pic_count=pic_count+1;
if (pic_count==4)
{
pic_count=0;
}
}
<img id="im" border=1><table border="1" width="37%" id="contain">
<tr>
<td width="274"> </td>
<td> </td>
</tr>
<tr>
<td width="274"> </td>
<td> </td>
</tr>
<tr>
<td width="274"> </td>
<td> </td>
</tr>
</table>
<script language="javascript">
<!--
var pic_path_array=[
'http://tucoo.com/icon/Yazoo%20smilies/s/Cool.png',
'http://tucoo.com/icon/Yazoo%20smilies/s/Huh!.png',
'http://tucoo.com/icon/Yazoo%20smilies/s/Love.png',
'http://tucoo.com/icon/Yazoo%20smilies/s/Tongue.png']
var pic_title_array =['Cool','Huh!','Love','Tongue']
var pic_count=0;
function loadpic() {
var pic=document.getElementById("im");
pic.src=""+pic_path_array[pic_count];
pic.width="128";
pic.height="128";
var tb=document.getElementById("contain");
tb.rows[2].cells[0].innerText=pic_title_array[pic_count];
pic_count=pic_count+1;
if (pic_count>=4) { pic_count=0; }
}
window.setInterval("loadpic()",3000)
//-->
</script></body>