kwilove
2015-06-14 15:57
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成功</p>
<span id="countTime"></span> <a href='javascript:goBack()'>返回</a>
<script type="text/javascript">
var second = 5;
//获取显示秒数的元素,通过定时器来更改秒数。
var message = document.getElementById("countTime");
function clock()
{
if(second==0)
{
goTo();
}
else
{
message.innerHTML = second-- + "秒后回到主页";
window.setTimeout(clock,1000);
}
}
clock();
//通过window的location和history对象来控制网页的跳转。
function goTo()
{
window.location.href = "http://www.baidu.com";
}
function goBack()
{
// window.history.Back();
window.location.href = "http://www.sina.com";
}
</script>
</body>
</html>
收藏了,赞
JavaScript进阶篇
468728 学习 · 22064 问题
相似问题