读书人

js钟表显示

发布时间: 2012-09-12 09:21:30 作者: rapoo

js时钟显示

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>时钟 TIME</title><script type=text/javascript>function startTime(){var today = new Date();var h = today.getHours();var m = today.getMinutes();var s = today.getSeconds();h=check(h);m=check(m);s=check(s);document.getElementById("show").innerHTML=h+"<font size='20'>:</font>"+m+"<font size='20'>:</font>"+s;t=setTimeout('startTime()',500);}function check(n){if(n<10){n = "0"+n;}return "<font size=20 color='red'>"+n+"</font>";}</script></head><body onLoad="startTime()"><br/><br/><div align = "center" id = "show"></div></body></html>

读书人网 >JavaScript

热点推荐