如何在jsp页面中获取系统时间并实时更新???急急急急急!!

解决方案 »

  1.   

    利用框架类定时向服务器请求时间,类似csdn论坛
    或者使用ajax如果是只是显示客户端时间可以使用js timeout函数设置,循环刷新
      

  2.   

    <html>
    <HEAD>
    <TITLE>Dynamic Content</TITLE>
    </HEAD>
    <body>
    <font face="verdana,arial,helvetica" size="+2">An HTML Clock</font><br>
    <div id=Clock align=center style="font-family: Verdana; font-size: 60; color:#0000FF">&nbsp;</div><script>
    <!--
    function tick() {
      var hours, minutes, seconds, ap;
      var intHours, intMinutes, intSeconds;
      var today;  today = new Date();  intHours = today.getHours();
      intMinutes = today.getMinutes();
      intSeconds = today.getSeconds();  if (intHours == 0) {
         hours = "12:";
         ap = "Midnight";
      } else if (intHours < 12) { 
         hours = intHours+":";
         ap = "A.M.";
      } else if (intHours == 12) {
         hours = "12:";
         ap = "Noon";
      } else {
         intHours = intHours - 12
         hours = intHours + ":";
         ap = "P.M.";
      }  if (intMinutes < 10) {
         minutes = "0"+intMinutes+":";
      } else {
         minutes = intMinutes+":";
      }  if (intSeconds < 10) {
         seconds = "0"+intSeconds+" ";
      } else {
         seconds = intSeconds+" ";
      }   timeString = hours+minutes+seconds+ap;  Clock.innerHTML = timeString;  window.setTimeout("tick();", 100);
    }window.onload = tick;
    -->
    </script>
    </body>
    </html>