<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script>
            function runme(){
                var nowDate = new Date();
                var year = nowDate.getYear();
                var month = nowDate.getMonth();
                var date = nowDate.getDate();
                
                var hour = nowDate.getHours();
                var min = nowDate.getMinutes();
                var sec = nowDate.getSeconds();
                
                var which = nowDate.getDay();
                
                var finalString = year + "-" + month + "-" + date + " " + hour + ":" + min + ":" + sec;
                
                switch (which) {
                    case 0:
                        which = "星期日";
                        break;
                    case 1:
                        which = "星期一";
                        break;
                    case 2:
                        which = "星期二";
                        break;
                    case 3:
                        which = "星期三";
                        break;
                    case 4:
                        which = "星期四";
                        break;
                    case 5:
                        which = "星期五";
                        break;
                    case 6:
                        which = "星期六";
                        break;
                        
                }
                finalString = finalString + " " + which;
                // document.write(finalString);
                document.getElementById("test").innerHTML = finalString;
               // document.body.innerText = finalString;
            }
            
            window.setInterval("runme()", 100);
        </script>
    </head>
    <body id="test">
     1111111
1

    </body>
</html>

解决方案 »

  1.   

    顺序执行,你可以在<script>中第一行添加一个alert();看一下效果。
      

  2.   

    body不行 我知道先执行script 但是  1111111
    1为什么不给我执行 
      

  3.   

    body已经执行  在100毫秒后值已被改变  时间调大点就能看到效果
      

  4.   

    那window.setInterval("runme()", 100);这个 函数 是先执行他  还是 先执行body那
      

  5.   

    4楼说的对,可以将settimeout函数的时间设长一点,这样就可以看到效果了