function sleep(s){
s = s || 0
s = parseInt(s) * 1000
let now = +new Date()
let timer = null
return new Promise((resolve, reject)=>{
timer = setInterval(()=>{
if( now + s < +new Date()){
clearInterval(timer)
resolve(true)
}
}, 10)
})
}
window.onload =async function(){
for(var i=5i>0i--)
await sleep(1)
alert('显示图片')
}
</script>
<!doctype html><html>
<head>
<meta charset="utf-8">
<title>倒计时</title>
<script type="text/javascript">
function GetRTime(){
var EndTime= new Date('2014/08/12 16:00:00') //截止时间
var NowTime = new Date()
var t =EndTime.getTime() - NowTime.getTime()
var d=Math.floor(t/1000/60/60/24)
var h=Math.floor(t/1000/60/60%24)
var m=Math.floor(t/1000/60%60)
var s=Math.floor(t/1000%60)
document.getElementById("t_d").innerHTML = d + "天"
document.getElementById("t_h").innerHTML = h + "时"
document.getElementById("t_m").innerHTML = m + "分"
document.getElementById("t_s").innerHTML = s + "秒"
}
setInterval(GetRTime,1000)
</script>
</head>
<body>
<div id="CountMsg" class=HotDate>
<span id="t_d"></span>
<span id="t_h"></span>
<span id="t_m"></span>
<span id="t_s"></span>
</div>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)