<html>
<head>
<script type="text/javascript">
function timedMsg()
{
document.write(" World!"); 
var t=setTimeout("reloadpage()",3000);
 
}
function reloadpage()
{
 
window.location.reload();
document.write("another World!"); 
}</script>
</head>
 <body onload="timedMsg()">
 
 
</body></html>
程序有错误啊。但不知道错在哪里了

解决方案 »

  1.   

    document.write只能在文档载入中使用,在文档载入完成后使用会把当前文档刷掉
      

  2.   

    这个问题,我解决了
    <script type="text/javascript">function reloadpage()
    {
     
    window.location.reload();
      
    document.write("another World!");  
    }
      </script><html>
    <body>
     
    <script type="text/javascript">
     
    document.write(" World!"); 
    var t=setTimeout("reloadpage()",3000);
     
    </script>
    </body>
    </html>
    我就是想每隔三秒显示新的文字。这个好像只能实现第一个三秒。
      

  3.   

    function timedMsg(){ 
      document.body.innerHTML = "World!";
      var t = setTimeout("reloadpage()", 3000);
    }
    function reloadpage(){
      document.body.innerHTML = "another World!";
    }
      

  4.   

    解释:
    关键是timedMsg()函数里面第一句 "不能"有 document.write(" World!"); 因为其会马上使web 页面变成document.write之后的的状态,之前那个状态执行已经完成了,只不过我们察觉不到而已
    ,到后面的状态时就看不到刷新了,去掉 timedMsg()函数里面 document.write(),如下试看可以看到有效果了,晚3秒执行
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script type="text/javascript" language="javascript">
    function timedMsg()
    {
    setTimeout("reloadpage()",3000); 
    }
    function reloadpage() 

    window.location.reload(); 
    document.write("another World!"); 
    }timedMsg();
    </script>
    <body>
    <input type="button" name="btn01" value="click" onClick="javascript:timedMsg();">
    </body>
    </html>
      

  5.   

    不想多说,请运行—<script type="text/javascript"> document.write("\
             World!\
             <script type=\"text/javascript\">\
                     setTimeout(function(){\
                                 document.close();\
                                 document.write(\"another World!\")\
                     }, 3000)\
             <\/script>\
    ");</script> 
      

  6.   


    <script type="text/javascript" defer> 
    document.body.innerHTML = "World!";
    setInterval(function(){
                document.body.innerHTML = document.body.innerHTML == "World!" && 
                "another World!" || "World!";
    }, 3000)
    </script>