JS倒計時跳轉頁面

來源:互聯網
上載者:User

標籤:cat   dex   log   navigator   redirect   app   type   lang   location   

這裡給大家提供一個好用的JS寫的倒計時頁面,就像一些網站上點提交後出現的倒計時頁面類似。

頁面代碼簡單,直接拷貝就能運行,頁面可以自己美化下。

 1  <!--這裡定義倒計時開始數值--> 2  3 <span id="totalSecond">5</span> 4  5  <!--定義js變數及方法--> 6  7 <script language="javascript" type="text/javascript"> 8 var second = document.getElementById(‘totalSecond‘).textContent; 9 10 if (navigator.appName.indexOf("Explorer") > -1)11 {12 second = document.getElementById(‘totalSecond‘).innerText; 13 } else14 {15 second = document.getElementById(‘totalSecond‘).textContent; 16 }17 18 19 setInterval("redirect()", 1000); 20 function redirect()21 {22 if (second < 0)23 {24 25  <!--定義倒計時後跳轉頁面-->26 location.href = ‘default.aspx‘; 27 } else28 {29 if (navigator.appName.indexOf("Explorer") > -1)30 {31 document.getElementById(‘totalSecond‘).innerText = second--; 32 } else33 {34 document.getElementById(‘totalSecond‘).textContent = second--; 35 }36 }37 }38 </script>

 

JS倒計時跳轉頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.