![]() |
#2
永夜的极光2007-10-19 10:52
打开记事本,复制以下代码,然后保存为index.html,然后直接双击用浏览器打开,查看效果
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" /> <title></title> <script language=JavaScript> var timerID = null; var timerRunning = false; function stopclock (){ if(timerRunning) clearTimeout(timerID); timerRunning = false;} function startclock () { stopclock(); showtime();} function showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = \"\" +((hours >= 12) ? \"下午 \" : \"上午 \" ) if(hours<=4){timeValue=\"凌晨\";} if(hours>4&&hours<=11){timeValue=\"上午\";} if(hours>11&&hours<=13){timeValue=\"中午\";} if(hours>13&&hours<=18){timeValue=\"下午\";} if(hours>18&&hours<=24){timeValue=\"晚上\";} timeValue += ((hours >12) ? hours -12 :hours) timeValue += ((minutes < 10) ? \":0\" : \":\") + minutes timeValue += ((seconds < 10) ? \":0\" : \":\") + seconds document.clock.thetime.value = timeValue; timerID = setTimeout(\"showtime()\",1000); timerRunning = true;} </SCRIPT> </head> <body topmargin=\"0\"> <table width=\"760\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <form name=clock> <td bgcolor=\"#eef0f8\" align=\"center\"><input name=thetime type=\"text\" style=\"font-size: 12pt;color:#000000;border:0;background-color: #eef0f8;\" size=\"12\" readonly=\"true\"> </td> </form> <script language=\"javascript\"> startclock (); </script> </tr> </table> </body> </html> [此贴子已经被作者于2007-10-19 10:54:10编辑过] |
