這樣寫數(shù)字為什么不變?
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <h4>操作成功</h4>
? <p>
????? <b id="select">5</b>自動返回主頁<a href="javaScript:goBack();">返回</a>
? </p>
? <script type="text/javascript">?
?? var sel=document.getElementById("select");
?? var i=5;
?? function set(){
?????? sel.innerHTML=i;
? ??? ?i--;
? ??? ?setTimeout("set()",1000);
? ??? ?if(i==1){
? ??? ??? ?window.location.href="http://idcbgp.cn";
? ??? ?}
?? }
?? function goBack(){
? ??? ?window.history.back();
?? }
?</script>
</body>
</html>
2016-12-15
因為根本沒有調(diào)用set函數(shù)啊,我加上一個調(diào)用就行了
?<script type="text/javascript"> ?
? setTimeout("set()",1);
? ?var sel=document.getElementById("select");
? ?var i=5;
? ?function set(){
? ? ? ?sel.innerHTML=i;
? ? ? ?i--;
? ? ? ?setTimeout("set()",1000);
? ? ? ?if(i==1){
? ? ? ? ? ?window.location.href="http://idcbgp.cn";
? ? ? ?}
? ?}