当标签不可见时,jQuery进度栏会暂停

时间:2018-09-23 22:03:40

标签: php jquery

1&1实现了每封电子邮件之间10秒钟的垃圾邮件减少时间间隔,因此这次我使用了jquery进度栏进行填充,然后重新加载页面以发送下一封电子邮件。

但是,当选项卡不可见时,进度条将停止并且不会继续。无论选项卡不可见,如何强制它运行?

function move() {
	var elem = document.getElementById("myBar"); 
	var width = 1;
	var id = setInterval(frame, 100);
	function frame() {
		if (width >= 100) {
			clearInterval(id);
			window.location.href = "{$nextpage}"
		} else {
			width++; 
			elem.style.width = width + '%'; 
		}
	}
}
$(document).ready(move());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Current message: {$xplusone} of {$revisedlist_length}<br>
                Current recipient: {$to_name} &lt;{$revisedlist[$x][0]}&gt;<br>
                Status of send: {$result}<br>
                <br>
                Total submited: {$sendlist_length}<br>
                Blacklisted: {$excludedlist_length}<br>
                Revised list: {$revisedlist_length}<br>
                <br>
                To observe anti-spam interval ({$send_interval} seconds), this page will reload after that time has elapsed...
                
                <br><br>
                <div id="myProgress" style="width: 100%; background-color: grey;">
                    <div id="myBar" style="width: 1%; height: 30px; background-color: green;"></div>
                </div>
                <br><br>
                
                <div class="col-xs-5">&nbsp;</div>
                <button type="button" class="btn btn-warning btn-lg col-xs-2" onclick="window.location.href='escape.php';">Escape</button>
                <div class="col-xs-5">&nbsp;</div>
                <br>

0 个答案:

没有答案