两个问题
1、
 var timeid=nullvar
 timerunning=false
null后面的var接错了,应该换行
2、 if(hours>18&&<=24)
少了个hours

解决方案 »

  1.   

    <head>
    <script language="JavaScript" type="text/JavaScript">
     var timeid=null
     var timerunning=false
    function stoptime()
    {
     
      if(timerunning)
      { clearTimeout(timeid)
        timerunning=false
      }  
    }
    function starttime()
    {
       stoptime()
       showtime() 
     }
    function showtime()
    {
     var now=new Date()
     var hours=now.getHours()
     var minutes=now.getMinutes()
     var seconds=now.getSeconds()
     var timevalue= " "+((hours>12)?hours-12:hours)
      timevalue+=((minutes<10)?":0":":")+minutes
      timevalue+=((seconds<10)?":0":":")+seconds
      if(hours>=6&&hours<=12)
        {timevalue=timevalue+"上午"}
      if(hours>12&&hours<=18)
       { timevalue+=("下午")}
      if(hours>18&&hours<=24)
      {timevalue+=("晚上")}  document.clock.face.value=timevalue
      timeid=setTimeout("starttime()",1000)
      timerunning=true
      
    }
    </script>
    </head>
    <body onLoad="starttime()">
    现在时刻是
    <form name="clock" on submit="0"><input type="text" name="face"  size=12></form>
    </body>
      

  2.   

    <head > 
    <script > 
     var timeid =null;
     timerunning = false;
     
    function stoptime() 
    {
     
      if( timerunning) 
      { 
    clearTimeout( timeid) ;
        timerunning = false;
      }  
    }function starttime() 
    {
       stoptime() ;
       showtime()  ;
     }
     
    function showtime() 
    {
    var now = new Date();
    var hours =  now.getHours(); 
    var minutes = now.getMinutes();
    var seconds = now.getSeconds() ;
    var timevalue =  " " + ( ( hours > 12) ? hours - 12 : hours);
     timevalue += ( ( minutes<10) ? ":0" : ":" )  + minutes;
     timevalue += ( ( seconds<10) ? ":0" : ":")  + seconds;
    if( hours >=  6 && hours <= 12) 
    {
       timevalue = timevalue + "上午"
    }
    if( (hours > 12) && (hours <= 18)) 

    timevalue += ( "下午"); 
    }
    if( (hours > 18) && (hours <= 24)) 
    {
    timevalue += ( "晚上") ;
    }  document.clock.face.value = timevalue;
     timeid = setTimeout( "starttime() ",1000) ;
     alert(timeid);
     timerunning = true;  
    }</script > 
    </head > 
    <body onLoad = "starttime() " > 
    现在时刻是
    <form name = "clock" onsubmit = "0" > <input type = "text" name = "face"  size = 12 > </form > 
    </body >