有花不见叶
2016-07-16 10:18
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<h4>操作成功</h4>
<span><a id="miao">5</a>秒后回到主页<a href="wy">返回</a></span>
<script type="text/javascript">
var num=5;
function sj(){
num=num-1;
miao.innerHTML=num;
setTimeout(sj,1000);
while(num<1){
var wy=window.location.href;
window.history.go(wy);
}
}
setTimeout(sj,1000);
</script>
</body>
</html>
<!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <h4>操作成功</h4> <span><a id="miao">5</a>秒后回到主页<a href="wy">返回</a></span> <script type="text/javascript"> var num=5; function sj(){ num=num-1; miao.innerHTML=num; setTimeout(sj,1000); // while(num<1){ //这里是个死循环!!!!! if(num==0){//改为判断 var wy=window.location.href; window.history.go(wy); } //可以在方法中从新执行 setTimeout(sj,1000); } //setTimeout 这个只会执行一次 setTimeout(sj,1000); </script> </body> </html>
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h4>操作成功</h4>
<!-- 返回点击后市返回上一级网页,5秒后返回主页 -->
<span><a id="miao">5</a>秒后回到主页<a href="javascript:window.location.go(-1)">返回</a></span>
<script type="text/javascript">
var num=5;
function sj(){
num=num-1;
miao.innerHTML=num;
setTimeout(sj,1000);
if(num<1){
window.location.href = "http://www.imooc.com/";
}
}
//启动函数,执行1次
setTimeout(sj,1000);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1>
<p>
<span id="num">5</span>秒后返回到主页 <a href="javascript:window.history.go(-1)">返回</a>
</p>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
function settime(){
var num=document.getElementById('num').innerHTML;
num--;
document.getElementById('num').innerHTML=num;
if(num==0){
window.location="http://www.imooc.com/";
}
}
setInterval(settime,1000);
//通过window的location和history对象来控制网页的跳转。
</script>
</body>
</html>
JavaScript进阶篇
468195 学习 · 21891 问题
相似问题