這里給大家提供一個好用的JS寫的倒計時頁面,就像一些網站上點提交后出現的倒計時頁面類似。
頁面代碼簡單,直接拷貝就能運行,頁面可以自己美化下。
<!--這里定義倒計時開始數值--><span id="totalSecond">5</span><!--定義js變量及方法--><script language="javascript" type="text/javascript">var second = document.getElementById('totalSecond').textContent;if (navigator.appName.indexOf("Explorer") > -1){second = document.getElementById('totalSecond').innerText; } else{second = document.getElementById('totalSecond').textContent; }setInterval("redirect()", 1000); function redirect(){if (second < 0){ <!--定義倒計時后跳轉頁面-->location.href = 'default.aspx'; } else{if (navigator.appName.indexOf("Explorer") > -1){document.getElementById('totalSecond').innerText = second--; } else{document.getElementById('totalSecond').textContent = second--; }}}</script>以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持武林網!
新聞熱點
疑難解答