為什么結果不會跳轉,還回出現負秒數???真是搞不懂
? <script type="text/javascript"> ?
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ? var ?time=document.getElementById("sec").innerHTML;
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function count(){
? ? ? ?time--;
? ? ? ?document.getElementById("sec").innerHTML=time;
? ? ? ?if(time==0)
? ? ? ?{
? ? ? ? ? ?location.assign("www.xianlaiwan.cn");
? ? ? ?}
? }
? setInterval("count()",1000);
? function back(){
? ? ? window.history.back();
? }
?</script>?
2017-01-03
你這個代碼沒問題啊,我復制下來測試了,除了不能跳轉成功原因是網址沒加"http://"
2017-01-03
<script type="text/javascript"> ?
? ? var ?time=5; //直接來個數字
? ?function count(){
? ? ? ?time--;
? ? ? ?document.getElementById("sec").innerHTML=time;
? ? ? ?if(time==0)
? ? ? ?{
? ? ? ? ? ?location.href="www.xianlaiwan.cn";
? ? ? ?}
? }
?setInterval("count()",1000);
?</script>?