<!DOCTYPE html><html> ???<head> ???????<title> ???????????浏览器对象 ???????</title> ???????<!-- 通过JS实现错误页面中在指定的时间跳到主页 --> ???????<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> ???</head> ???<body> ???????<!--先编写好网页布局--> ???????<h3> ???????????操作成功 ???????</h3> ???????<p> ???????????<b id="second"> ???????????????5 ???????????</b> ???????????秒后回到主页 ???????????<a href="javascript:goBack();"> ???????????????返回 ???????????</a> ???????</p> ???????<script type="text/javascript"> ?????????????//获取显示秒数的元素,通过定时器来更改秒数。 ?????????????var sec = document.getElementById("second"); ?????????????var i=5; ?????????????var timer = setInterval(function(){ ?????????????????i--; ?????????????????sec.innerHTML = i; ???????????????????if(i ==1){ ?????????????????????window.location.href="http://baidu.com"; ?????????????????} ?????????????},1000) ?????????????????????????????//通过window的location和history对象来控制网页的跳转。 ??????????????function goBack(){ ??????????????????window.history.go(-1); ??????????????} ???????</script> ???</body></html>
通过JS实现错误页面中在指定的时间跳到主页
原文地址:https://www.cnblogs.com/hglibin/p/9693751.html