JavaScript十六进制时间_日期时间特效

模板酷站
  •       4/5
  •       1
  •       2
  •       3
  •       4
  •       5
查看演示效果

      织梦DedeCMS视频教程买空间 租服务器 选网硕互联! 无忧站长工具,百度权重一键全查!

      以十六进制显示时间,很晕哦,不知道你能看懂不?偶看不懂是什么,不知道为什么要这样搞,或许有其它用途吧。

      <html> <head> <title>十六进制显示时间</title> <meta http-equiv="mrc-Type" mrc="text/html;charset=gb2312"> </head> <body> <script language="JavaScript"> function syeClock() { if (!document.layers && !document.all) return; timePortion = new Array; maxLength = new Array; var runTime = new Date(); timePortion[0] = runTime.getHours(); timePortion[1] = runTime.getMinutes(); timePortion[2] = runTime.getSeconds(); maxLength[0] = 5; maxLength[1] = 6; maxLength[2] = 6; var decValue = 0; var decMod = 0; var temp = ""; var hoursBackground = "#7B7BB5"; var minutesBackground = "#4D5487"; var secondsBackground = "#424A63"; var colonBackground = "#000000"; var textColor = "#FFFFFF"; for (var curPor = 0; curPor <= 2; curPor++) { decValue = timePortion[curPor]; timePortion[curPor] = ""; while (decValue != 0) { decMod = decValue % 2; decValue = Math.floor(decValue / 2); timePortion[curPor] = decMod + timePortion[curPor]; } if (timePortion[curPor].length < maxLength[curPor]) { for (var i = 1; i <= maxLength[curPor] - timePortion[curPor].length; i++) { temp += "0"; } } timePortion[curPor] = temp + timePortion[curPor]; temp = ""; } movingtime = '<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor='+ hoursBackground +'><font color='+ textColor +'>' + timePortion[0] + '</font></td><td bgcolor='+ colonBackground +'>:</td><td bgcolor='+ minutesBackground +'><font color='+ textColor +'>' + timePortion[1] + '</font></td><td bgcolor='+ colonBackground +'>:</td><td bgcolor='+ secondsBackground +'><font color='+ textColor +'>' + timePortion[2] + '</font></td></tr></table>'; if (document.layers) { document.layers.clock.document.write(movingtime); document.layers.clock.document.close(); } else if (document.all) { clock.innerHTML = movingtime; } setTimeout("syeClock()", 1000) } window.onload = syeClock; </script> 现在时间:<br> <span id="clock" style="position:relative;"></span> </body> </html>