js超时器倒计时跳转特效
css代码:
<style type="text/css">
.seconds {
height: 50px;
background: #eee;
line-height: 50px;
border-radius: 5px;
text-align: center;
font-size: 18px;
font-family: 微软雅黑;
}
.seconds span {
font-size: 23px;
font-weight: bold;
color: #f00;
margin: 0 5px 0 5px;
}
#btn {
width: 100px;
height: 35px;
border: 0;
background: #333;
color: #fff;
border-radius: 6px;
cursor: pointer;
}
</style>
html代码:
<div class="seconds">
用户注册成功,页面
<span id="second">3</span>秒后即将跳转...
<button id="btn">停止跳转</button>
</div>
js代码:
<script>
seconds=document.getElementById('second');
btn=document.getElementById('btn');
shenTime=setTimeout(function(){
location="http://www.baidu.com";
},3000);
btn.onclick=function(){
clearTimeout(shenTime)
};
</script>
浙公网安备 33010602011771号