莫892897612
2018-09-13 11:21
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<h2>操作成功</h2>
<span id="second">5</span>
<span>秒后回到主页</span>
<a href="javascript:hanshu();">返回</a>
<!--先编写好网页布局-->
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var sum=document.getElementById("second").innerHTML;
function aaa(){
sum--;
document.getElementById("second").innerHTML=sum;
if(sum==0){
window.location.assign("www.baidu.com");
}
}
setInterval("aaa()",1000);
//通过window的location和history对象来控制网页的跳转。
function hanshu(){
window.history.go(-1);
}
</script>
</body>
</html>
JavaScript进阶篇
469404 学习 · 22585 问题
相似问题