Skip to content

Instantly share code, notes, and snippets.

@wynnzen
Last active August 29, 2015 14:05
Show Gist options
  • Save wynnzen/a824c5b7d902781b7bd6 to your computer and use it in GitHub Desktop.
Save wynnzen/a824c5b7d902781b7bd6 to your computer and use it in GitHub Desktop.
back to the page
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h3>操作成功</h3>
<span id="sec">5</span>秒后回到主页
<button onclick="goback();">返回 </button>
<script type="text/javascript">
var sec = document.getElementById("sec");
var time = 5;
var t = window.setInterval(function(){
if(time<1){
clearInterval(t);
window.location = "http://baidu.com";
return;
}
sec.innerHTML = time;
time--;
},1000);
//通过window的location和history对象来控制网页的跳转。
function goback(){
window.history.back();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment