Html倒计时图片代码?
发布网友
发布时间:2022-05-05 00:57
我来回答
共1个回答
热心网友
时间:2022-06-28 00:43
<script type="text/javascript">
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=5;i>0;i--)
await sleep(1)
alert('显示图片')
}
</script>