2018-07-30  9 views 评论

JS在HTML中实现五秒倒计时

 标签:
<p>页面将会在<span id="mes">5</span>秒钟后返回 <a href="http://www.guanchazhe.top/">首页</a>!</p>
<script language="javascript" type="text/javascript">
var i = 5;
var intervalid;
intervalid = setInterval("fun()", 1000);
function fun() {
if (i == 0) {
window.location.href = "http://www.guanchazhe.top/";
clearInterval(intervalid);
}
document.getElementById("mes").innerHTML = i;
i--;
}
</script>

给我留言

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

看不清?