settimeout

Using setTimeout to bypass IE script warning

Hi, I'm trying to write a web app that uses Javascript to perform a fairly complex calculation (involves factorials and Bessel functions). When I run the script in IE, it gives me a warning that the script is unresponsive or taking a long time, and asks if I want to continue running it. I've read that to get around this, you can use e...

Alternatives to setTimeout after an Ajax callback

I find myself doing this a lot: window.onload = function(){ $.get("http://example.com/example.html", function(data) { $('#contentHere').html(data); setTimeout("javaScriptClass.init()", 200); }); } But setTimeout seems a bit hacky (and 200ms is already over three times the attention span of the average user :). ...

How to write a factorial function in Javascript using setTimeout or setInterval

Hi all, I asked a question a couple weeks ago about using setTimeout for a factorial function, but it was unfortunately with an unregistered account and I never got a complete answer. My main issue is that I'd like to write a function that calculates the factorial of a number but uses the setTimeout or setInterval commands. The impetu...

How to know if a timer is cleared or timed out in javascript?

Ok, really simple question. I'm taking a crash course in javascript. If I use timer = setTimeout(..., 500) to set a timer, and then clearTimeout(timer) to clear the timer, the integer value of timer doesn't change, so my question is how to know if a timer is timed out or cleared? I want to use if (timer) {...} , but obviously a positi...

A problem with setTimeout

I recently asked a question about the same function, that solved my probelem and directed me to a tutoraial because I was using a while loop, this meant that my function did not animate, just freeze then resize. This new way, using setTimeout should work. The only thing is that it just snaps to the new size rather than animating to it. T...

How can I execute a setTimeout() only when the user is present (with the mouse movement) with jQuery

I have a function that updates a <div /> via AJAX: function update() { <!-- .ajax() --> setTimeout(update(), 3000);} } What I need is that this is not executed when the user is not present on the website, so if there is no movement of the mouse (we will suppose that if move it is in the website) it will not update .mousemove(...

Increase Div Width with Javascript setTimeout()

How can we increase or Decrease width of a DIV using setTimeout() ?? ...

setInterval /clearInterval dropdown issues

Hi, I want to make a dropdown menu using jquery, but it closes even it shouldn't. I have an element which is subscribed to the mouseenter event, mouse enters the element, the dropdown, fires up, everything seems to be ok. I go down to the item list which is list element with some content in it. The first time i change the two elements e...

unable to refresh a page when i use setInterval() and pass in a function that uses document.write to output some javascript to the page

basically i have a blank html page that includes a javascript file, and in the javascript file i have this: function doIt() { document.writeln("asdf"); } // could also be setTimeout setInterval("doIt()", 5000); When the html page loads, it waits 5 seconds and then will output "asdf" every 5 seconds to the screen. If i hit refresh or...

Why does firebug say my function call is "undefined"

I have a navigation menu which contain sub menus. On hover I want the sub menus to show after a second delay. Menu items marked with a class of "more" contain sub menus. Problem is that one of my functions called hoverCheck() is coming back as undefined when it's called. But I can't figure out why. Here's my code: $(document).ready...

How to use setInterval or setTimeout with a for loop?

I am trying to set an interval when some code runs but only need to do it based on the number of elements there are. Here's a quick example: 5 total elements Run code once every 20 seconds for each element that is found. Can someone please give me a basic example how to do this using plain JavaScript? Everything I have tried just exec...

Why does this setTimeout code build up and not terminate?

If you click the body of the html once and wait until the ball is offscreen its fine. However if you clicked 2+ times you'll notice the ball moving faster. When you click the body again to make the ball come back it is still faster then it should be. Why? http://jsfiddle.net/44nwt/10/ -edit- in firefox on my page (i havent tried on jsfi...