...

View Full Version : code executes in wrong order?



NancyJ
05-05-2006, 08:51 AM
I'm having a problem with code executing in the wrong order. I have 2 things I want to do at a given point in the program, however in IE, this isnt working unless an alert is placed between the 2, so I tried to simulate an alert by using a custom wait function so it should execute the first line, wait for 1second and then execute the second line. This is not what happens. The wait happens first. so in FF it waits 1s then does the first line then the second. In ie it waits 1s then does the second and the last doesnt appear to run, so it maybe that its doing the 3rd line before the 1st line.


document.getElementById("quote").innerHTML = xmlhttp.responseText;
waitFor(1000);
registerEvents();

Philip M
05-05-2006, 09:04 AM
Does this help?

http://www.codingforums.com/showthread.php?t=85158

NancyJ
05-05-2006, 11:57 AM
I think I know what the issue is - everyline is executed in order, but without waiting for the previous line to finish... which seems odd to me but I've managed to cobble together a workaround using setTimeout()

Philip M
05-05-2006, 04:49 PM
As one nut to another :cool:

I have also encountered this or something similar:-

Here is a small fragment of some code I cobbled to get round the problem:-

var blurReset = 1;
//............
if (blurReset == 1) { // do a whole raft of things
//................
if (entry) {thenumber.value = tpyrcne(entry)}
blurForm(thenumber);
}
return false;
}

// ----------------------------------------

function blurForm(thenumber) {
thenumber.blur(); // required to overcome bug in IE
blurReset = 0;
setTimeout ("blurReset = 1", 250); // quarter of a second delay
document.forms[0].NextField.focus();
}

Hope this points you in the right direction. It is a long time since I fixed
this IE problem so I have forgotton some of the details.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum