settimeout

How to refresh or reload a page with timeout in javascript or jquery

梦想的初衷 提交于 2020-01-06 17:46:08
问题 How can I refresh or reload a page with timeout in javascript or jquery only when a specific class is visible or img is not found i found this https://stackoverflow.com/a/14787543/7051635 but there is no timeout and when i'm in front of an omg not found, nothing happened. 回答1: Use the setTimeout() global method to create a timer. This will reload the page after 5000 milliseconds (5 seconds): setTimeout(function(){ location.reload(); }, 5000); This code can be added to any event you need it to

setInterval and setTimeout

半城伤御伤魂 提交于 2020-01-05 10:36:48
问题 var myTimer = setInterval(function(){ var eleID = ''; var delayTimer = ''; $('#hp-fcas li').each(function(i) { eleID = $(this).attr('id'); delayedTrigger( $('#'+eleID + ' a'), 7000*i); }); function delayedTrigger(elem, delay){ setTimeout(function(){ $(elem).trigger('click'); }, delay ); } }, 21000); $(".play").click(function(){ clearTimeout(); clearInterval(myTimer); }); The first interval is 21 seconds, of the first instance. the 2nd interval is 3 7-second instances (what I want). I'm trying

setInterval and setTimeout

别来无恙 提交于 2020-01-05 10:35:27
问题 var myTimer = setInterval(function(){ var eleID = ''; var delayTimer = ''; $('#hp-fcas li').each(function(i) { eleID = $(this).attr('id'); delayedTrigger( $('#'+eleID + ' a'), 7000*i); }); function delayedTrigger(elem, delay){ setTimeout(function(){ $(elem).trigger('click'); }, delay ); } }, 21000); $(".play").click(function(){ clearTimeout(); clearInterval(myTimer); }); The first interval is 21 seconds, of the first instance. the 2nd interval is 3 7-second instances (what I want). I'm trying

setInterval and setTimeout

瘦欲@ 提交于 2020-01-05 10:35:07
问题 var myTimer = setInterval(function(){ var eleID = ''; var delayTimer = ''; $('#hp-fcas li').each(function(i) { eleID = $(this).attr('id'); delayedTrigger( $('#'+eleID + ' a'), 7000*i); }); function delayedTrigger(elem, delay){ setTimeout(function(){ $(elem).trigger('click'); }, delay ); } }, 21000); $(".play").click(function(){ clearTimeout(); clearInterval(myTimer); }); The first interval is 21 seconds, of the first instance. the 2nd interval is 3 7-second instances (what I want). I'm trying

jQuery UI progressbar on a timer

佐手、 提交于 2020-01-05 09:47:58
问题 I have a progressbar on the top of my page that I'm using to display the 1 minute timer used to refresh all the charts. The problem I'm having is that it never seems to be consistent. function headerBar() { var progressbar = $('#timerBar'); progressbar.progressbar({ value: 0 }); function progress() { var val = progressbar.progressbar('value') || 0; progressbar.progressbar('value', val + 5); if (val < 99) { setTimeout(progress, 3000); } } progress(); } headerBar(); setInterval(function () {

jQuery UI progressbar on a timer

人盡茶涼 提交于 2020-01-05 09:47:46
问题 I have a progressbar on the top of my page that I'm using to display the 1 minute timer used to refresh all the charts. The problem I'm having is that it never seems to be consistent. function headerBar() { var progressbar = $('#timerBar'); progressbar.progressbar({ value: 0 }); function progress() { var val = progressbar.progressbar('value') || 0; progressbar.progressbar('value', val + 5); if (val < 99) { setTimeout(progress, 3000); } } progress(); } headerBar(); setInterval(function () {

Javascript: Iterate through array of URLs and open, then close at defined interval

做~自己de王妃 提交于 2020-01-05 08:21:48
问题 I have an array of URLs that I need to loop through and open in a new window. However, I need to be able to set a timeout between each window's open and close. In other words, the window should only stay open for a set interval, then move on to the next URL in the array. The following code opens the windows, but only closes the first one. (function X() { document.getElementById("target").onclick = function () { var urlList = ['http://www.google.com', 'http://www.msn.com', 'http://www.yahoo

Javascript: Iterate through array of URLs and open, then close at defined interval

梦想的初衷 提交于 2020-01-05 08:21:33
问题 I have an array of URLs that I need to loop through and open in a new window. However, I need to be able to set a timeout between each window's open and close. In other words, the window should only stay open for a set interval, then move on to the next URL in the array. The following code opens the windows, but only closes the first one. (function X() { document.getElementById("target").onclick = function () { var urlList = ['http://www.google.com', 'http://www.msn.com', 'http://www.yahoo

What happens when setTimeout < 5 node.js

假装没事ソ 提交于 2020-01-05 05:27:07
问题 Objective Find out the true behavior of setTimeout(fn, X) when X-> 0. Background I am developing a tool that makes QPS (Queries Per Second) tests, using setTimeout() . I was recently surprised when I made a test of 1000 QPS that took roughly 5 seconds to execute when it should have taken 1 (not counting any other external factors). The tests works fine for lower values of QPS, bellow 100 for example. While investigating, I found some articles explaining that when making setTimeout(fn, X)

使用setTimeout模拟setInterval效果

纵然是瞬间 提交于 2020-01-05 01:40:05
  由于现在部分浏览器基于对系统性能的优化,在使用setInterval的时候,在页面没有获得关注的状态,浏览器可以会自动将setInterval终端,等到该页面重新获得关注时再开启。这样就会使得一些基于setInterval的定时效果出现意想不到的问题;   解决的办法就是使用setTimeout来模拟setInterval的效果。   具体实现过程如下: var i = 0;function time(){ //每隔1秒让++i console.log(++i); setTimeout(time,1000); } time(); //执行time函数 btn.onclick = function(){ time = null; //重写time函数,从而起到关闭定时器的效果 } 来源: https://www.cnblogs.com/hellobajie/p/5558417.html