Internet explorer automation busy v/s readystate property

12,711

From here:

Michael Harris (MVP) wrote:

        [...]
        do until ie.readyState = 4 : wscript.sleep 10 : loop
        [...]


    Is there a reason to use
      do until ie.readyState = 4 : wscript.sleep 10 : loop
    instead of
      While ie.Busy : WScript.Sleep 10: Wend
    [...]

Just based on past experience in lots of different IE automation scenarios I observed that IE.Busy was not 100% reliable in determining the fully loaded state of the document. It appeared .Busy would oscillate true/false/true/... under some circumstances before the .ReadyState finally arrived at 4 (complete).

That oscillating behavior may have been a bug that is fixed in current versions, but it seems to me more likely that the description of Busy is better than it once was (at least as I recall reading it many years ago). It states simply that IE is busy with navigation or downloading and says nothing explicitly about any connection with the various states the document itself goes through as the DOM is built and page is actually rendered in the browser UI.

The problems avoided by using .ReadyState rather than .Busy are errors thrown in script trying to access/manipulate in incomplete DOM.

Share:
12,711
codeomnitrix
Author by

codeomnitrix

Young | Enthusiastic | Ecstatic | Raw Programmer | Counter-Strike

Updated on June 28, 2022

Comments

  • codeomnitrix
    codeomnitrix almost 2 years

    I am new to vbscript and while reading i found some code as

    Do While ie.busy
    stateString = stateString & " " & cstr(ie.readystate)
    loop
    do while ie.readystate <> 4
    stateString = stateString & " " & ie.readystate
    loop
    

    so could anyone please let me know what is difference between the busy property and readystate property.

  • orad
    orad over 9 years
    Thanks for sharing your experience.