settimeout

setTimeout in loop to check for a change in bounds

被刻印的时光 ゝ 提交于 2019-12-11 03:09:36
问题 This is my code: var b; while(!b){ setTimeout(function(){ alert('sss') b=1; }, 500); } and it will not alert 'sss' What can i do? Updated: I want to get bounds on google maps v3: function get_bounds(){ var bounds_; while(!bounds_){ setTimeout(function(){ bounds_=map.getBounds(); if(bounds_){ var leftBottom=[bounds_.getSouthWest().lat(),bounds_.getSouthWest().lng()] var rightTop=[bounds_.getNorthEast().lat(),bounds_.getNorthEast().lng()] return [leftBottom,rightTop]; } }, 500); } } updated2:

fadeOut first div then fadeIn second div

故事扮演 提交于 2019-12-11 03:08:07
问题 got a problem i need to do something like a fading banner - one div fading out then second div fading in, here's the code: $(document).ready(function() { setTimeout(function() { $('#zeus').fadeOut(1000); }, 5000); $('#zeuss').hide(); setTimeout(function(){ $('#zeuss').fadeIn(1000); }, 6000); }); it works, but after #zeuss fades in then it just stays here. I need to do that repeatedly. And please don't offer to use .delay() because im on jquery 1.3.2 EDIT. by default #zeus is shown on the page

Is there a need to prepend setTimeout and setInterval with window object?

家住魔仙堡 提交于 2019-12-11 02:45:33
问题 In the Mozilla documentation, there are some examples written with window. in front of the timer functions and some without: function delayedAlert() { timeoutID = window.setTimeout(slowAlert, 2000); }... setTimeout(myArray.myMethod, 1000);... window.setInterval = function (vCallback, nDelay... I have been writing my code without window. in front without any problem so far. I want to find out if there is any situation when it would be necessary. 回答1: If .. There is no other identifier in scope

setTimeout takes longer than it should

喜夏-厌秋 提交于 2019-12-11 02:29:04
问题 Could someone please explain why the script, below with the setTimeout command, takes a lot longer to execute (400-500 ms) in Greasemonkey than it does in the Firefox console, where it's exactly 100 ms? var start = new Date ().getTime (); console.log ( new Date ().getHours ()+" : " + new Date ().getMinutes () + " : " + new Date ().getSeconds () + " : " + new Date ().getMilliseconds () ); setTimeout (foo,100); //foo (); function foo () { var time = new Date () - start; console.log ("Execution

JavaScript setTimeout() duplicates

余生颓废 提交于 2019-12-11 02:12:03
问题 I'm fairly new to JavaScript/jQuery, but have made a script to change the background picture. First Script The first script version works fine and does the following: creates a setInterval timer that calls function backgroundChange() to run every 7 seconds decides the next picture URL sets the background picture This works great, but the problem is when the website is live, on a slow connection the background picture doesn't load in time for the next timer change. New Script So the new

Trouble using setTimeout function

♀尐吖头ヾ 提交于 2019-12-11 01:52:39
问题 I've never been able to properly use the setTimeout function, so I tried writing a sample script to update a progress bar, but again, it does not work. Instead, the entire program runs before the progress bar is updated to 100%. Would somebody be able to look at this code and tell me what I'm doing wrong? The code I'm trying to use is from http://digitalbush.com/projects/progress-bar-plugin/ Thanks! <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content=

Why does JavaScript setTimeout lag when in another tab?

戏子无情 提交于 2019-12-11 01:46:05
问题 I am using setTimeout to run a JavaScript program that will use AJAX to fetch external data and update the content of the page once every 1000 milliseconds, or one second. This works perfectly fine when the tab that my web page is on is in the forefront. However, if the page is running in a browser window with multiple tabs, and the user is not currently in that tab, then the setTimeout will begin to lag (in one minute, rather than updating 60 times, it only updates around 30). However, if

setTimeout in a JQuery animation

百般思念 提交于 2019-12-11 01:36:21
问题 I'm having a problem with the setTimeout(). I want, in the mouseout state, that the submenu slides Up after a interval (500 miliseconds). But the setTimeout() isn't working. Like in this link: http://jsfiddle.net/felipepalazzo/Xyhvn/2/ The code: (function($){ $.fn.showMenu = function(options){ var settings = $.extend({ height : '40px', speed : '500', heightx : '20px' }, options || {}); return this.each(function(){ var elem = $(this); var menu_timer; elem.hover(function(){ $(this).stop()

SSL Connection timeout and read timeouts

空扰寡人 提交于 2019-12-11 01:12:11
问题 I have a doubt on where to set the socket timeout within my code. What I am trying to achieve is that when the socket is created the timeout should be 10seconds. So I am setting it before the handshake. now the error that I see in the logs are of two kinds. 1) Connection Timeout Error and 2) Read timeout Error. So I was wondering if anyone could explain me more about where to set the timeouts. I have the following code: try{ SSLSocketFactory factory=(SSLSocketFactory)SSLSocketFactory

How to use jQuery Deferred (when/then, etc.) to fix asynchroneous pyramid of doom issue

余生颓废 提交于 2019-12-11 01:08:37
问题 I've been puzzling for quite a while trying to wrap my head around JavaScript promises. I want to fix some issues with asynchroneous calls in my code, to de-spagethise it. But I'd love for an expert to help me, because I've wasted quite some time already. I want to use the jQuery Deferreds for it, since I'm using jQuery (v1.11) in my project already, and I don't want to add any more libraries (already have over 5). I read that the jQuery doesn't fully follow the Promises/A spec, but I figured