本帖最后由 codefish123 于 2011-04-18 14:58:58 编辑

解决方案 »

  1.   

    <html>
    <body>
    <div id=time></div>
    <script>
    function show() 

    now=new Date(); 
    year=now.getYear(); 
    month=now.getMonth()+1; 
    date=now.getDate(); 
    hours=now.getHours(); 
    minutes=now.getMinutes(); 
    seconds=now.getSeconds();     
    if(minutes<=9) 
    minutes="0"+minutes;
    if(seconds<=9) 
    seconds="0"+seconds;
    document.getElementById("time").innerHTML = year + "年" + month + "月" + date + "日" + "现在时间:" + hours + ":" + minutes + ":" + seconds;setTimeout("show()",1000); 
    }
    show();
    </script> 
    </body>
    </html>
    按照上面的改下就可以。
      

  2.   

    innerHTML绝对不能改成document.write()来实现
    document.write()只能在页面加载的时候使用