function a()
{ ad=Math.round(Math.random()*(banner.length-1))
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner[ad] + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt[ad] + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
}
setTimeout("a()",2000);

解决方案 »

  1.   

    setTimeout('a()',2000)换成setInterval('a()',2000)
      

  2.   

    document.write会把你整个文档清空,再写内容,所以你的程序也被清空了,建议用div的innerHTML来做
      

  3.   

    setTimeout('a()',2000)换成setInterval('a()',2000)我试过,不行
      

  4.   

    document.write会把你整个文档清空,再写内容,所以你的程序也被清空了,建议用div的innerHTML来做可以写详细点吗?
      

  5.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><!-- 步骤一: 把以下数据复制到你的Html文件的Body标记下  -->
    <BODY>
    <div id="ad"></div>
    <SCRIPT LANGUAGE="JavaScript"><!-- Begintxt="欢迎到上海科学技术出版社来";
    url="http://www.sstp.com.cn";
    alt=new Array("上海科学技术出版社","adasdas");
    banner=new Array("D:\My Documents\My Pictures\2.gif","D:\My Documents\My Pictures\3.gif");
    height="54";
    width="350";function aaa()
    { var ad=Math.round(Math.random()*(banner.length-1)); var s=""; s +="<center>";
    s +="<a href=\"' + url + '\" target=\"_top\">";
    s +="<img src=\"" + banner[ad] + "\" width=";
    s += width + " height=" + height + " ";
    s +="alt=\"" + alt[ad] + "\" border=0><br>";
    s +="<small>" + txt + "</small></a>";
    s +="</center>";

    document.getElementById('ad').innerHTML = s; var t = setTimeout("aaa()",2000);
    }
    aaa();
    // End -->
    </SCRIPT></BODY>
    </html>
      

  6.   

    谢谢ttyp,
    不知道怎么把分数给你,
    (第一次来这里)