代码中 document.getElementById("second").innerHTML=sum;的作用是什么?为什么跳转的网址显示不出来?<a href="目标网址">才是啊,为什么是<a href="javascript:???
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<h2>操作成功</h2>
<span id="second">5</span>
<span>秒后回到主页</span>
<a href="javascript:hanshu();">返回</a>
<!--先编写好网页布局-->
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var sum=document.getElementById("second").innerHTML;
function aaa(){
sum--;
document.getElementById("second").innerHTML=sum;
if(sum==0){
window.location.assign("www.baidu.com");
}
}
setInterval("aaa()",1000);
//通过window的location和history对象来控制网页的跳转。
function hanshu(){
window.history.go(-1);
}
</script>
</body>
</html>