10秒后跳转到指定页面
<body>
<h1>操作成功</h1>
<p><span id="counts">10</span>秒后回到主页 <a href="javascript:back();">返回</a></p>
<script type="text/javascript">
var count=document.getElementById("counts").innerHTML;
function countTimer()
{
count--;
//获取显示秒数的元素,通过定时器来更改秒数。
document.getElementById("counts").innerHTML=count;
if(count==0)
{
location.assign("www.imooc.com");
}
}
setInterval("countTimer()",1000);
//通过window的location和history对象来控制网页的跳转。
function back()
{
window.history.back();
}
</script>
</body>
744

被折叠的 条评论
为什么被折叠?



