不知道哪兒錯了
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta charset="UTF-8">
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h1>操作成功</h1>
? <p><span id="second">5</span>秒后回到主頁<a href="javascript:goBack();">返回</a>? ?</p>
??
? <!--獲取顯示秒數的元素,通過定時器來更改秒數。-->
?
? <script type="text/javascript">??
? var num=5;
? function startCount(){
? ? ? document.getElementById("second").innerHTML=num;
? ? ? num=num-1;
? ? ? if(num==0){
? ? ? ? ? window.location.;
? ? ? }
? ? ?setInterval("startCount()",1000);
? }
? function goBack(){
? ? ? window.location.forward();
? }
?
??
? ?//通過window的location和history對象來控制網頁的跳轉。?
?</script>?
</body>
</html>
2019-03-14
startCount函數出問題了
? ? function startCount()
? ? {
? ? ? ? num=num-1;
? ? ? ? document.getElementById("second").innerHTML=num;
? ? ? ? if(num==0)
? ? ? ? {
? ? ? ? ? ? window.location.assign("http://www.baidu.com");
? ? ? ? }
? ? }
? ? setInterval("startCount()",1000);
? ? function goback()
? ? {
? ? ? ?window.history.back();
? ?}