Internet explorer automation busy v/s readystate property

前端 未结 1 1907
甜味超标
甜味超标 2020-12-10 21:36

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         


        
1条回答
  •  醉梦人生
    2020-12-10 21:59

    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.

    0 讨论(0)
提交回复
热议问题