Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    code executes in wrong order?

    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.
    Code:
     document.getElementById("quote").innerHTML = xmlhttp.responseText;
    		    waitFor(1000);
    		   registerEvents();

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,027
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Does this help?

    lag on IE with SetInterval

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    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()

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,027
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    As one nut to another

    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.
    Last edited by Philip M; 05-05-2006 at 03:58 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •