document.clock.time.value=timestr;
  document.clock.date.value=datestr;
  把上面语句的clock去掉,你的html里没有clock节点

解决方案 »

  1.   

    timestr+=((minutes<10):"0":"")+minutes;
    timestr+=((seconds<10):"0":"")+seconds;
    三目 ":" 改为 "?"
      

  2.   


    <html>
      <head>
        <title>网页时钟操作</title>
        <script language="javascript">
          var timestr,datestr;
          function clock(){
            now=new Date();
            hours=now.getHours();
            minutes=now.getMinutes();
            seconds=now.getSeconds();
            timestr=""+hours+":";
    //        timestr+=((minutes<10):"0":"")+minutes;
            timestr+=((minutes<10)?"0":"")+minutes+":";
    //        timestr+=((seconds<10):"0":"")+seconds;
            timestr+=((seconds<10)?"0":"")+seconds;
            document.clock.time.value=timestr;
            
            date=now.getDate();
            month=now.getMonth()+1;
    //        year=now.getYear();
            year=now.getFullYear();
            datestr=month+"/";
            datestr+=((date<10)?"0"+date:date)+"/";
            datestr+=year;
            document.clock.date.value=datestr;
    //        timer=setTimeOut("clock()",1000);
            timer=setTimeout("clock()",1000);
          }
        </script>
      </head>
      <body onload=clock()>
          <!--form-->
          <form name=clock>
          时间:
          <input type="text" name=time size=10 value=""><br>
          日期:
          <input type="text" name=date size=10 value=""><br>
        </form>
      </body>
    </html>
      

  3.   


    <html>
      <head>
        <title>网页时钟操作</title>
        <script language="javascript">
          var timestr,datestr;
          function clock(){
            now=new Date();
            hours=now.getHours();
            minutes=now.getMinutes();
            seconds=now.getSeconds();
            timestr=""+hours+":";
    //        timestr+=((minutes<10):"0":"")+minutes;
            timestr+=((minutes<10)?"0":"")+minutes+":";
    //        timestr+=((seconds<10):"0":"")+seconds;
            timestr+=((seconds<10)?"0":"")+seconds;
            document.clock.time.value=timestr;
            
            date=now.getDate();
            month=now.getMonth()+1;
    //        year=now.getYear();
            year=now.getFullYear();
            datestr=((month<10)?"0"+month:month)+"/";
            datestr+=((date<10)?"0"+date:date)+"/";
            datestr+=year;
            document.clock.date.value=datestr;
    //        timer=setTimeOut("clock()",1000);
            timer=setTimeout("clock()",1000);
          }
        </script>
      </head>
      <body onload=clock()>
          <!--form-->
          <form name=clock>
          时间:
          <input type="text" name=time size=10 value=""><br>
          日期:
          <input type="text" name=date size=10 value=""><br>
        </form>
      </body>
    </html>