日期:2014-05-16 浏览次数:20328 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> JS动态时间展示(兼容IE/FIREFOX) </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content="YanXiaoJia"> </head> <script type="text/javascript"> <!-- function startTime() { var today=new Date() var years=today.getFullYear(); var months=today.getMonth(); var d=today.getDate() var h=today.getHours() var m=today.getMinutes() var s=today.getSeconds() // add a zero in front of numbers<10 months=months+1 months=checkTime(months) d=checkTime(d) m=checkTime(m) s=checkTime(s) var weekday=new Array(7) weekday[0]="星期日" weekday[1]="星期一" weekday[2]="星期二" weekday[3]="星期三" weekday[4]="星期四" weekday[5]="星期五" weekday[6]="星期六" var w=weekday[today.getDay()] document.getElementById('ShowTime').innerHTML=years+"年"+months+"月"+d+"日 "+w+" "+h+":"+m+":"+s; t=setTimeout('startTime()',500) } function checkTime(i) { if(i<10){ i="0" + i } return i } --> </script> <body onload="startTime()"> <div id="ShowTime"></div> </body> </html>