<script language="javascript">
var imglist = new Array("one.gif","two.gif","three.gif","four.gif");
function displayImage()
{
  myimg.src= imglist[Math.floor(Math.random()*imglist.length)];
  setTimeout("displayImage()",1000);
}
</script>
<body onload='setTimeout("displayImage()",1000)'>
<img id="myimg" src="one.gif">
</body>
 

解决方案 »

  1.   

    为什么不能把"<img id="myimg" src="one.gif">"放入<form></form>中,放入后出错?
      

  2.   

    change 
    myimg.src= imglist[Math.floor(Math.random()*imglist.length)];
    to
    document.all("myimg").src= imglist[Math.floor(Math.random()*imglist.length)];
      

  3.   

    karma(无为),谢谢你的回答,再请教:
    <MAP NAME="DMAP">
    <AREA SHAPE="RECT" COORDS="115,102,139,121" HREF="O2b-L.jpg" onMouseOver="sr('O2b.jpg')" onMouseOut="si('sign_gray.gif')">
    <AREA SHAPE="RECT" COORDS="88,113,112,127" HREF="O2a-L.jpg" onMouseOver="sr('O2a.jpg')" onMouseOut="si('sign_gray.gif')">
    有办法取得区域的数据吗(COORDS="115,102,139,121")?
      

  4.   

    if you get hold of the area element, say, it is obj, you can do obj.coords
      

  5.   

    try this
    http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/imagemap.htmsave the source to a local html
    add
    <base href="http://msdn.microsoft.com">
    before 
    <BODY> tag
    and add this to each AREA
    onmouseover="window.status=this.coords;"like this:
    <AREA SHAPE="rect" COORDS="0,0,82,126" HREF="/workshop/graphics/sun.gif" alt="sun" onmouseover="window.status=this.coords;">move over the image, watch the status bar