Jquery 实现倒计时跳转到指定页面或关闭窗口

<p>项目中需要增加一个投票功能,投票完成后自动倒计时 10 秒跳转到首页。</p><p>JavaScript 代码:</p><p>// 设置超时时间为 10 秒钟</p><p>var timeout = 10;</p><p>function show() {</p><p> var showbox = $(&quot;.showbox&quot;);</p><p> showbox.html(timeout);</p><p> timeout--;</p><p> if (timeout == 0) {</p><p> window.opener = null;</p><p> window.location.href = &quot;index.aspx&quot;;</p><p> }</p><p> else {</p><p> setTimeout(&quot;show()&quot;, 1000);</p><p> }</p><p>}</p>
RangeTime:0.007368s
RangeMem:204.23 KB
返回顶部 留言