Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

vbscript - Internet explorer automation busy v/s readystate property

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...