10月
12
2017

纯JS页面电子时钟

好久不写代码了,拼拼凑凑也就能做点小东西来玩了

js液晶电子时钟

适用于各种秒杀、抢票、投票神马的需要等待开始时间的页面,适合收藏在浏览器书签里,随用随点开。

代码有点丑,将就用吧哈哈

javascript:var timebox=document.createElement("div");timebox.id="timebox";timebox.style="width: 300px; height: 70px; color: #8e8e8e; background-color: #313131; text-align: center; position: fixed; line-height: 70px; left: 50px; top: 50px; z-index: 9999; font-family: 'LCDMono2'; font-size: 60px;border-radius: 7px;";document.body.appendChild(timebox);function checkTime(i){if(i<10){i="0"+i}return i}function time(){clearTimeout(t);dt=new Date();var h=checkTime(dt.getHours());var m=checkTime(dt.getMinutes());var s=checkTime(dt.getSeconds());var spliter=(s%2==0)?":":" ";document.getElementById("timebox").innerHTML=h+":"+m+spliter+s;t=setTimeout(time,1000)}var t=null;t=setTimeout(time,1000);

用法,浏览器新建书签,标题随便,网址粘入上述代码即可:

js液晶电子时钟

此外,页面使用了等宽液晶字体,安装本地后才能出最佳效果:LCDM2U__

关于作者:moface

博主

留下评论