html自动计时器,html css js 时钟 计时器

编程知识 更新时间:2023-04-04 17:40:11

时钟

html>

菜鸟教程(runoob)

var _hmt = _hmt || [];

(function() {

var hm = document.createElement("script");

hm.src = "http://hm.baidu/hm.js?8e2a116daf0104a78d601f40a45c75b4";

var s = document.getElementsByTagName("script")[0];

s.parentNode.insertBefore(hm, s);

})();

var H='....';

var H=H.split('');

var M='.....';

var M=M.split('');

var S='......';

var S=S.split('');

var Ypos=0;

var Xpos=0;

var Ybase=8;

var Xbase=8;

var dots=12;

function clock(){

var time=new Date ();

var secs=time.getSeconds();

var sec=-1.57 + Math.PI * secs/30;

var mins=time.getMinutes();

var min=-1.57 + Math.PI * mins/30;

var hr=time.getHours();

var hrs=-1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;

for (i=0; i 

document.getElementById("dig" + (i+1)).style.top=0-15+40*Math.sin(-0.49+dots+i/1.9).toString() + "px";

document.getElementById("dig" + (i+1)).style.left=0-14+40*Math.cos(-0.49+dots+i/1.9).toString() + "px";

}

for (i=0; i 

document.getElementById("sec" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(sec).toString() + "px";

document.getElementById("sec" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(sec).toString() + "px";

}

for (i=0; i 

document.getElementById("min" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(min).toString() + "px";

document.getElementById("min" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(min).toString() + "px";

}

for (i=0; i 

document.getElementById("hour" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(hrs).toString() + "px";

document.getElementById("hour" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(hrs).toString() + "px";

}

setTimeout('clock()',50);

}

window.οnlοad=clock;

div.dig, div.hour, div.min, div.sec

{

position:absolute;

}

div.hour, div.min, div.sec

{

width:2px;

height:2px;

font-size:2px;

}

div.dig

{

width:30px;

height:30px;

font-family:arial,verdana,sans-serif;

font-size:10px;

color:#000000;

text-align:center;

padding-top:10px

}

div.min

{

background:#0000FF;

}

div.hour

{

background:#000000;

}

div.sec

{

background:#FF0000;

}

1 2 3 4 5 6 7 8 9 10 11 12

计时器

html>

菜鸟教程(runoob)

var c1 = 0;

var t=0;

var timer_is_on1= 0 ;

function myTimer(){

t=t+1;

document.getElementById("txt").value=t;

}

function doTimer1(){

if (!timer_is_on1) {

timer_is_on1 = 1;

myt = setInterval(function () {

myTimer()

},1000);

}

}

function stopCount1(){

clearInterval(myt);

timer_is_on1=0;

}

计时器2

html>

菜鸟教程(runoob)

var c=0;

var t;

var timer_is_on=0;

function timedCount(){

document.getElementById('txt').value=c;

c=c+1;

t=setTimeout(function(){timedCount()},1000);

}

function doTimer(){

if (!timer_is_on){

timer_is_on=1;

timedCount();

}

}

function stopCount(){

clearTimeout(t);

timer_is_on=0;

}

单击开始计数按钮,按下时开始计数,输入框将从0开始一直计数。单击停止计数按钮,按下时停止计数,再次点击开始计数按钮,又再次开始计数。

更多推荐

html自动计时器,html css js 时钟 计时器

本文发布于:2023-04-04 17:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/8ec02845c7e5e4f96d47ce48e7c23fd4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计时器   时钟   html   js   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 43044文章数
  • 14阅读数
  • 0评论数