JS实现网页自动跳转
2016-10-24 15:12
453 查看
效果图:(5秒后跳转到百度)
示例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<style type="text/css">
#dv{border:4px #E8E8E9 double;margin:auto;width:600px;height:300px;
background-color:#E8E8E8;
/*设置透明度*/
filter:alpha(opacity=50); -moz-opacity:0.6; -khtml-opacity: 0.6; opacity: 0.6;
}
.top{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:12px;}
.top li{border:0px #00FF00 solid;width:180px;height:40px;float:left;list-style:none;
text-height:40px;line-height:40px;
}
.top .top_one{width:70px;height:40px;margin-left:80px;}
.top #setTime{color:#900;width:30px;height:40px;font-size:36px;text-align:center;}
.bottom{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:160px;}
.bottom li{border:0px #00FF00 solid;width:120px;height:40px;float:left;list-style:none;
line-height:40px;
}
.bottom .bottom_one{width:100px;height:40px;margin-left:220px;}
.bottom .bottom_two{width:70px;height:40px;}
.bottom .bottom_two a:hover{color:#F00;}
.bottom .bottom_two a{text-decoration:none;color:#0F0;}
</style>
</head>
<body bgColor="#f7f7f7">
<div id = "dv" >
<ul class="top">
<li class="top_one">网页将在</li>
<li id="setTime"></li>
<li>秒后自动跳转......</li>
</ul>
<ul class="bottom">
<li class="bottom_one">如果未跳转请</li>
<li class="bottom_two"><a href="http://www.baidu.com">点击此处</a></li>
</ul>
</div>
<!--定时器-->
<script type="text/javascript">
var i = 5;
var tId;
document.getElementById("setTime").innerHTML = i;
function showTime(){
if(i == 0){
window.clearInterval(tId);
return;
}
i--;
document.getElementById("setTime").innerHTML = i;
if(i == 0){
//如果时间秒数为0,跳转到指定页面
location.replace("http://www.baidu.com");
}
}
window.setInterval(showTime,1000);
</script>
<!--保持网页不变形-->
<script type="text/javascript">
var a=screen.availWidth;
var b=screen.availHeight;
window.moveTo(0,0)
window.resizeTo(a,b)
</script>
</body>
</html>
示例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<style type="text/css">
#dv{border:4px #E8E8E9 double;margin:auto;width:600px;height:300px;
background-color:#E8E8E8;
/*设置透明度*/
filter:alpha(opacity=50); -moz-opacity:0.6; -khtml-opacity: 0.6; opacity: 0.6;
}
.top{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:12px;}
.top li{border:0px #00FF00 solid;width:180px;height:40px;float:left;list-style:none;
text-height:40px;line-height:40px;
}
.top .top_one{width:70px;height:40px;margin-left:80px;}
.top #setTime{color:#900;width:30px;height:40px;font-size:36px;text-align:center;}
.bottom{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:160px;}
.bottom li{border:0px #00FF00 solid;width:120px;height:40px;float:left;list-style:none;
line-height:40px;
}
.bottom .bottom_one{width:100px;height:40px;margin-left:220px;}
.bottom .bottom_two{width:70px;height:40px;}
.bottom .bottom_two a:hover{color:#F00;}
.bottom .bottom_two a{text-decoration:none;color:#0F0;}
</style>
</head>
<body bgColor="#f7f7f7">
<div id = "dv" >
<ul class="top">
<li class="top_one">网页将在</li>
<li id="setTime"></li>
<li>秒后自动跳转......</li>
</ul>
<ul class="bottom">
<li class="bottom_one">如果未跳转请</li>
<li class="bottom_two"><a href="http://www.baidu.com">点击此处</a></li>
</ul>
</div>
<!--定时器-->
<script type="text/javascript">
var i = 5;
var tId;
document.getElementById("setTime").innerHTML = i;
function showTime(){
if(i == 0){
window.clearInterval(tId);
return;
}
i--;
document.getElementById("setTime").innerHTML = i;
if(i == 0){
//如果时间秒数为0,跳转到指定页面
location.replace("http://www.baidu.com");
}
}
window.setInterval(showTime,1000);
</script>
<!--保持网页不变形-->
<script type="text/javascript">
var a=screen.availWidth;
var b=screen.availHeight;
window.moveTo(0,0)
window.resizeTo(a,b)
</script>
</body>
</html>
相关文章推荐
- js如何实现网页自动跳转
- js实现网页多少秒后自动跳转到指定网址
- 网页在实现自动登录后,再跳转打开网页如何实现?
- 页面自动跳转的js实现
- js实现界面自动跳转
- js实现几秒后页面自动跳转
- 实现网页页面跳转的几种方法(meta标签、js实现、php实现)
- 实现网页之间自动跳转的方法
- js实现页面跳转,纯html实现网页定时跳转
- JS实现的网页无提示自动关闭
- 实现网页页面跳转的几种方法(meta标签、js实现、php实现)
- 百度Site App的uaredirect.js实现手机访问,自动跳转网站手机版
- 利用meta实现网页自动刷新和自动跳转
- js实现网页跳转的五种方法
- 使用js实现页面自动跳转
- JS实现网页几秒钟之后跳转
- META HTTP-EQUIV="refresh" 实现网页自动跳转
- JS 实现页面N秒钟自动跳转
- js实现网页自动刷新
- 实现网页页面跳转的几种方法(meta标签、js实现、php实现)