用到的主要方法:
1.setInterval(f, ms); 定时器
参数列表:js函数、毫秒
2.location.herf();跳转函数
参数:需要跳转的URL
<!DOCTYPE html>
<html>
<head>
<title>JS实现定时跳转</title>
<script>
window.οnlοad=function(){
var timeElement=document.getElementById("second");
var time=timeElement.innerHTML;
var times=setInterval(function() {
timeElement.innerHTML=time;
time--;
if(time==0){
clearInterval(times);
location.href="http://www.baidu.com";
}
}, 1000)
}
</script>
</head>
<body>
<h3>利用js实现倒计时跳转</h3><br>
开始计时<span id="second" style="color:red">5</span>s后跳转到百度首页,如果没有跳转点击<a href="www.baidu.com">这里</a>
</body>
</html>
页面
哦了~
最后
以上就是懵懂硬币最近收集整理的关于利用javaScript实现页面倒计时跳转的全部内容,更多相关利用javaScript实现页面倒计时跳转内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复