Preserved Topic: javascript has a fatal flaw - is there a way round? (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: Northumberland, England |
posted 06-28-2003 22:06
one thing I've noticed is that if you have a javascript that is set to do something at a particular event and then you start another piece of javascript using another event before the first has finished doing it's business then the first breaks. Can javascript only handle one event at a time? |
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 06-28-2003 22:36
hmm... I've never had any problems of this sort... |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-28-2003 23:09
I think you must be mistaken. As long as a piece of code is continuous (basically, as long as it uses no setTimeout or setInterval calls to "wait"), it cannot be interrupted by another event. I suggest that you strip your code down, bit by bit, in order to come up with the smallest piece of code which will reliably reproduce the problem you're having. In the process, you'll probably either figure out what's wrong, or if not, you can post the code here, and as long as you've made it small enough, we should be able to help figure out what's wrong. |
Paranoid (IV) Inmate From: Northumberland, England |
posted 06-29-2003 14:43
ok let me give you an example, i have no specific code to strip down but this is an example of something i've noticed many times. |
Nervous Wreck (II) Inmate From: Sweden, Malmoe |
posted 06-29-2003 16:40
But if one was to have two functions that both uses setTimeout and are going to be run line by line. Then is there a way to wait for the first function to finish, and not start the second function? |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 06-29-2003 22:40
I think you can do this. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 06-29-2003 23:23
quote:
|
Paranoid (IV) Inmate From: Den Haag, Netherlands |
posted 06-30-2003 11:20
I had the same problem many times in the past .. Nowadays, I set a variable loaded=false, as the very first instruction in my script, right as near to the top of the page as it's possible to get ... |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 07-02-2003 07:27
I have run into this problem in the past. It can occur not only with onLoad, but also if the user selects a link or presses a key combination that takes the browser away from the executing function. When the interupting function completes, it returns control to the browser, not to the interupted function. |