利用javaScript实现页面倒计时跳转
2018-02-27 20:19
531 查看
用到的主要方法:
1.setInterval(f, ms); 定时器
参数列表:js函数、毫秒
2.location.herf();跳转函数
参数:需要跳转的URL
<!DOCTYPE html>
<html>
<head>
<title>JS实现定时跳转</title>
<script>
window.onload=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>页面
1.setInterval(f, ms); 定时器
参数列表:js函数、毫秒
2.location.herf();跳转函数
参数:需要跳转的URL
<!DOCTYPE html>
<html>
<head>
<title>JS实现定时跳转</title>
<script>
window.onload=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实现动态倒计时跳转页面
- javascript实现倒计时自动跳转页面
- asp.net中倒计时自动跳转页面的实现方法(使用javascript)
- javascript实现倒计时跳转页面
- javascript实现页面倒计时跳转
- javascript实现倒计时跳转页面
- asp.net中倒计时自动跳转页面的实现方法(使用javascript)
- asp.net中实现倒计时自动跳转页面(运用javascript)
- 利用javascript实现页面跳转的几种方法
- Javascript 实现倒计时跳转页面代码
- Android利用CountDownTimer实现倒计时功能 Android实现停留5s跳转到登录页面
- 利用javascript实现页面跳转的几种方法
- JavaScript实现倒计时跳转页面功能【实用】
- 利用java filter 实现业务异常拦截 跳转到错误信息提示页面
- 利用intent-filter和html超链接实现页面跳转
- Javascript实现页面跳转的几种方式
- JavaScript实现时间倒计时跳转(推荐)
- Javascript实现页面跳转的几种方式
- JavaScript 实现页面跳转的方法