javascript的:<!-- Time-->
<html>
  <head>
    <title>Time</title>
        <style>
      body    { border: 0; background-color: buttonface; color: black; margin: 3px,0,0,0 }
      .clocktxt  { font-family: Arial; font-weight: normal; font-size: 8pt }
      #btnsd    { border: 2px groove white; background-color: buttonface; font-family: verdana; font-size: 9px }
    </style>
    <script language="JavaScript">
      //Clock Script
      var showclock;
    
      function init(){
        showdate()
        showclock=true;
      }
      
      function showdate(){
        //edit refresh rate here
        var refreshrate=1000;              var Clock=new Date()
              var hours=Clock.getHours()
              var minutes=Clock.getMinutes()
              var seconds=Clock.getSeconds()          var dn="AM"
                 if (hours>12){
                  dn="PM"
                  hours=hours-12
                }                if (hours==0) hours=12
          if (minutes<=9) minutes= "0" + minutes
                if (seconds<=9) seconds= "0" + seconds                //edit format here
          format  = hours+":"+minutes+":"+seconds+" "+dn;          Time.innerHTML=format;
          
            if (showclock==false) Time.innerHTML="<input type='button' value='Sh.time' id='btnsd' title='Show time'>" 
            else 
            setTimeout("showdate()",refreshrate)
            }
    </script>
  </head>
  <body scroll="no" onLoad="init()">
        <center>
        <font class="clocktxt"> <span id="Time" style="position:center;"></span></font>
<h1>test text!!!</h1>
  </body>
</html>

解决方案 »

  1.   

    //file name:Clock.javaimport java.awt.*;import java.util.Date;public class Clock extends java.applet.Applet implements Runnable{   Thread clockThread;  public void start(){ // 鍦ˋpplet鐨剆tart鏂规硶涓垱寤哄苟鍚姩绾跨▼    if(clockThread==null){       clockThread=new Thread(this,"Clock");      clockThread.start(); // 鍚姩    }  }  public void run(){    while(clockThread!=null){      repaint();      try{        clockThread.sleep(1000);      }      catch(Exception e){}    }  }  public void paint(Graphics g){ // 璋冪敤drawString鏂规硶鐢诲嚭鏃躲€佸垎銆佺    Font f=new Font("TimesRoman",Font.BOLD,24);    g.setFont(f);    Date now=new Date();    g.drawString(now.getHours()+":"+now.getMinutes()+":"+now.getSeconds(),20,40);  }  public void stop(){ // 鍦ˋpplet鐨剆top鏂规硶涓娇绾跨▼娑堜骸    clockThread=null; // 涔熷彲鐢╟lockThread.stop();  }}HTML鏂囦欢锛?<html><body><applet code="Clock.class" WIDTH=200 HEIGHT=70></applet></body></htmp> 
      

  2.   

    说明一下 applet小程序: 
    类文件Clock.class于html文件放在同一目录下。
      

  3.   

    <script>
    function scroll() 
    {
    dt=new Date();
    sec=dt.getSeconds();
    hr=dt.getHours();
    ampm="A.M.";
    smin=dt.getMinutes();
    if (hr >=12) ampm="P.M.";
    if (hr > 12) hr -=12;
    if (smin <= 9) smin = "0"+smin;
    if (sec <= 9)  sec = "0"+sec;
    if (hr  <= 9)  hr  = "0"+hr;
    var scroller="当前时间:"+hr+":"+smin+":"+sec+" "+ampm;
    var timeout=setTimeout("scroll()", 1000);
    clock.innerText=scroller;
     }
    </script>
    <table><tr><td id=clock>
    <script>scroll()</script>
      

  4.   

    <script Language="JavaScript"> 
    var timerID = null; 
    var timerRunning = false; function stopclock (){ 
    if(timerRunning) 
    clearTimeout(timerID); 
    timerRunning = false; 

    function showtime () { 
    var now = new Date(); 
    var year = now.getYear();
    var month= now.getMonth()+1;
    if (month<10)
    month = "0" + month;
    var days = now.getDate();
    if (days<10)
       days = "0" +days;
    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 
    timeValue += (hours >= 12) ? " P.M. " : " A.M. " 
    timeValue += "版权所有,不得翻录,违者必究";
    window.status = year+"-"+month+"-"+days+" "+timeValue; 
    timerID = setTimeout("showtime()",1000); 
    timerRunning = true; 

    function startclock () { 
    stopclock(); 
    showtime(); 

    </script> 
    <script language="javascript">
    startclock();
    </script>
      

  5.   

    谢谢大家的帮助,我的要求很简单,所以决定用shappin的代码。现在屡行我的承诺。