您的位置:首页 > 编程语言

2012世界末日倒计时代码 原来没事虚惊一场

2012-12-15 00:00 281 查看
这款时世界末日倒计时源代码,程序上有JS控制器,是用于网页中显示的倒计时器,自己可以设定世界末日的开始时间,网页倒计时世界末日源代码直接复制就可以用,无需下载,直接便可使用



网页倒计时世界末日源代码_js倒数世界之末日_脚本之家


function fu_count2012() {
var days = document.getElementById("countDays");
var hours = document.getElementById("countHours");
var minutes = document.getElementById("countMinutes");
var seconds = document.getElementById("countSeconds");
var timeTotal = new Date();
var mSecondTotal = timeTotal.getTime();
var timeTotal2012 = new Date(2012,11,21,0,0,0);
var mSecondTotal2012 = timeTotal2012.getTime();
var mtimes = mSecondTotal2012 - mSecondTotal;
var getDays = Math.floor(mtimes / 1000 / 60 / 60 / 24);
var getHours = Math.floor(mtimes / 1000 / 60 / 60 % 24);
var getMinutes = Math.floor(mtimes / 1000 / 60 % 60);
var getSeconds = Math.floor(mtimes / 1000 % 60);
getHours = (getHours < 10) ? "0"+getHours : getHours;
getMinutes = (getMinutes < 10) ? "0"+getMinutes : getMinutes;
getSeconds = (getSeconds < 10) ? "0"+getSeconds : getSeconds;
days.innerHTML = getDays;
hours.innerHTML = getHours;
minutes.innerHTML = getMinutes;
seconds.innerHTML = getSeconds;
setTimeout("fu_count2012()", 1000);
}
window.onload = fu_count2012;


body {
background: #000000;
color: #ffffff;
text-align: center;
}



距离2012年12月31日还有
天小时分钟秒





[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
<div id="container">离"世界末日"还有 <span id="downtime" style="color:red"></span></div> 
<script> 
function downTime(){ 
var timeout = window.setTimeout(downTime, 100); 
var endTime=new Date("12-21-2012 0:0:0");//改成你的计时日期 
var today=new Date(); 
var timeold=(endTime.getTime()-today.getTime()); 
if(timeold <= 100){ 
window.clearTimeout(timeout); 
document.getElementByIdx_x("container").innerHTML = "原来没事啊,虚惊一场!"; 
return; 
} 
var sectimeold=timeold/1000; 
var secondsold=Math.floor(sectimeold); 
var msPerDay=24*60*60*1000; 
var e_daysold=timeold/msPerDay; 
var daysold=Math.floor(e_daysold); 
var e_hrsold=(e_daysold-daysold)*24; 
var hrsold=Math.floor(e_hrsold); 
var e_minsold=(e_hrsold-hrsold)*60; 
var minsold=Math.floor((e_hrsold-hrsold)*60); 
var e_seconds=(e_minsold-minsold)*60; 
var seconds=Math.floor((e_minsold-minsold)*60); 
var decimals = Math.floor((e_seconds-seconds)*10); 
document.getElementByIdx_x("downtime").innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"."+decimals+"秒" ; 
} 
downTime(); 
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: