<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1>
<span id="seconds">5</span><span>秒后回到主页</span><a href="javascript:back()">返回</a>
<script type="text/javascript">
var num=documnet.getElementById("seconds").innerHTML;
alert(num);
function count()
{
num--;
document.getElementById("seconds").innerHTML=num;
if(num==0)
{
location.assign("http://baidu.com");
}
}
setInterval("count()",1000);
function back()
{
window.history.back();
}
</script>
</script>
</body>
</html>
var num=documnet.getElementById("seconds").innerHTML;拼写错啦,是document...........................
谢谢大神。。。
你获取的num是一个字符,转换成数字才能执行num--
var num=parseInt(documnet.getElementById("seconds").innerHTML);