<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1>
<p><span></span>秒后回到主页<a href="javaScript:back()">返回</a></p>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var i=5;
function count(){
if(i==0){
window.history.back();
}
var span = document.getElementsByTagName("span")[0];
span.innerHTML=i;
i--;
window.setTimeout("count()",1000);
}
count();
//通过window的location和history对象来控制网页的跳转。
function back(){
window.history.back();
}
</script>
</body>
</html>
<!DOCTYPE html><html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <h1>操作成功</h1> <br/> <script type="text/javascript"> let num = 5; var int = setInterval(count,1000); function count() { document.getElementById("txt").value = num+" 秒后返回到主页"; num = num - 1; if(num <= 0){ navigato(); } } function navigato() { window.history.back(); } </script> <form action=""> <input type="text" id="txt" size="11" style="border-style:none"> <a href="" onclick="navigato()">返回</a> </form></body></html>