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>
最后
以上就是拼搏过客最近收集整理的关于JS之页面自动跳转的全部内容,更多相关JS之页面自动跳转内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复