当前位置:首页 > 代码 > 正文

倒计时页面代码(倒计时页面代码怎么设置)

admin 发布:2022-12-19 22:29 123


今天给各位分享倒计时页面代码的知识,其中也会对倒计时页面代码怎么设置进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

JS倒计时页面代码(要求读取服务器时间)

用JavaScript获取服务器时间,然后做页面倒计时的程序代码如下:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" 

html xmlns="" xml:lang="en" lang="en"  

head  

meta http-equiv="Content-Type" content="text/html; charset=utf-8"/  

titleuntitled/title  

script type="text/javascript"

get=function (id){

return document.getElementById(id)

}  

if(document.all){  

window.XMLHttpRequest=function(){  

var get=['Microsoft.XMLHTTP','Msxml2.XMLHTTP'];  

for(var i=0;iget.length;i++)

{

  try{

   return new ActiveXObject(get[i])

   }

  catch(e){}

};  

};  

}  

webDate=function(fn){  

var Htime=new XMLHttpRequest();  

Htime.onreadystatechange=function(){

  Htime.readyState==4(fn(new Date(Htime.getResponseHeader('Date'))))

  };  

  Htime.open('HEAD', '/?_='+(-new Date));  Htime.send(null);  

}  

window.time=new Date();  

targetTime=new Date();  

time2String=function (t){  

with(t)return [getFullYear(),'年'  ,('0'+(getMonth()+1)).slice(-2),'月'  ,('0'+getDate()).slice(-2),'日 '  ,('0'+getHours()).slice(-2),': '  ,('0'+getMinutes()).slice(-2),': '  ,('0'+getSeconds()).slice(-2)].join('')  

}  

int2time=function (m){

  m-=(D=parseInt(m/86400000))*86400000;  m-=(H=parseInt(m/3600000))*3600000;  S=parseInt((m-=(M=parseInt(m/60000))*60000)/1000);  

  return D+'天'+H+'小时'+M+'分'+S+'秒'  

  }  

  setInterval(function (){ 

   webDate(function (webTime){  

         get('web').innerHTML=time2String(time=webTime);  

         })  

   get('locale').innerHTML=time2String(new Date);  

   get('time').innerHTML=int2time(targetTime-time);  

   if ((targetTime-time)0) {  

   get('time').innerHTML = 'Game Over';  

   }  },1000)  

/script  

/head  

body  

设定时间:2015年06月18日0时0分0秒br  服务器时间:span id='web'loading.../spanbr  

本地时间:span id="locale"loading.../spanbr  

倒计时时间:span id="time"loading.../span  

script type="text/javascript" charset="utf-8"  targetTime=new Date(2015,06,18,00,00,00);  /script  

/body 

/html

注:原理用xmlhttp来获取服务器上的时间,后台用js做倒计时显示到页面上,由于获取服务器时间这个在本地运行不一定能成功,最好是在服务器上运行!

倒计时html代码

倒计时的html代码:

!DOCTYPE HTML

html

head

meta charset="utf-8"

titleCSS3圆环倒计时-源码搜藏网/title

style

.pie { width:200px; height:200px; background-color:blue; border-radius:100px; position:absolute; }

.pie1 { clip:rect(0px,200px,200px,100px); -o-transform:rotate(0deg); -moz-transform:rotate(0deg); -webkit-transform:rotate(0deg); background:-moz-radial-gradient(20% 50% 0deg, #333, #0000ff); background:-webkit-gradient(radial, 100 100, 0, 100 100, 110, from(#000), to(#0000ff)); }

.pie2 { clip:rect(0px,100px,200px,0px); -o-transform:rotate(0deg); -moz-transform:rotate(0deg); -webkit-transform:rotate(0deg); background:-moz-radial-gradient(80% 50% 0deg, #333, #0000ff); background:-webkit-gradient(radial, 100 100, 0, 100 100, 110, from(#000), to(#0000ff)); }

.hold { width:200px; height:200px; position:absolute; z-index:1; }

.hold1 { clip:rect(0px,200px,200px,100px); }

.hold2 { clip:rect(0px,100px,200px,0px); }

.bg { width:200px; height:200px; background-color:red; border-radius:100px; position:absolute; box-shadow:0px 0px 8px #333; background:-moz-radial-gradient(0% 50% 0deg, #900, #ff0000); background:-webkit-gradient(radial, 100 100, 0, 100 100, 110, from(#900), to(#ff0000)); }

.time { width:160px; height:160px; margin:20px 0 0 20px; background-color:#fff; border-radius:100px; position:absolute; z-index:1; box-shadow:0px 0px 8px #333 inset; text-align:center; line-height:160px; font-family:"Book Antiqua", Palatino, serif; font-size:35px; font-weight:bold; text-shadow: 1px 1px 3px #333; }

.time em { background:#fff; position:absolute; top:62px; left:12px; height:18px; width:140px; opacity:0.4; }

/style

/head

body

div class="hold hold1"

  div class="pie pie1"/div

/div

div class="hold hold2"

  div class="pie pie2"/div

/div

div class="bg" /div

div class="time"span/spanem/em/div

script src=""/script 

script

i = 0;

j = 0;

count = 0;

MM = 4;

SS = 59;

MS = 9;

totle = (MM+1)*600;

d = 180*(MM+1);

MM = "0" + MM;

function showTime(){

totle = totle - 1;

if(totle==0){

clearInterval(s);

clearInterval(t1);

clearInterval(t2);

$(".pie2").css("-o-transform","rotate(" + d + "deg)");

$(".pie2").css("-moz-transform","rotate(" + d + "deg)");

$(".pie2").css("-webkit-transform","rotate(" + d + "deg)");

}else{

if(totle0  MS0){

MS = MS - 1;

if(MS  10){MS = "0" + MS};

};

if(MS==0  SS0){

MS = 10;

SS = SS - 1;

if(SS  10){SS = "0" + SS};

};

if(SS==0  MM0){

SS = 60;

MM = MM - 1;

if(MM  10){MM = "0" + MM};

};

};

$(".time span").html(MM + ":" + SS + ":" + MS);

};

s = setInterval("showTime()",100);

function start1(){

i = i + 0.6;

count = count + 1;

if(count==300){

count = 0;

clearInterval(t1);

t2 = setInterval("start2()",100);

};

$(".pie1").css("-o-transform","rotate(" + i + "deg)");

$(".pie1").css("-moz-transform","rotate(" + i + "deg)");

$(".pie1").css("-webkit-transform","rotate(" + i + "deg)");

};

function start2(){

j = j + 0.6;

count = count + 1;

if(count==300){

count = 0;

clearInterval(t2);

t1 = setInterval("start1()",100);

};

$(".pie2").css("-o-transform","rotate(" + j + "deg)");

$(".pie2").css("-moz-transform","rotate(" + j + "deg)");

$(".pie2").css("-webkit-transform","rotate(" + j + "deg)");

};

t1 = setInterval("start1()",100);

/script 

input onclick="window.open('view-source:' + window.location.href)" type="button" value="查看源代码" style="position:absolute; right:0; top:0; width:80px; height:30px;"

/body

/html

直接复制代码,创建html文件,然后复制进去,就可以看到效果了。

倒计时代码怎么写?

#python 倒计时代码

import time

count = 0

min = 10 #倒计时10个数

while (count min):

time.sleep(1)#倒计时休眠时间1秒。

print("\r%s" % str(min - count).center(20,'-'), end="") # 总长度20,字符居中,其余部分用'-'填空

count += 1

倒计时页面代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于倒计时页面代码怎么设置、倒计时页面代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/27721.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载