Vbscript Internet explorer自动化忙v/s readystate属性

Vbscript Internet explorer自动化忙v/s readystate属性,vbscript,browser-automation,Vbscript,Browser Automation,我是vbscript新手,在阅读时发现一些代码如下 Do While ie.busy stateString = stateString & " " & cstr(ie.readystate) loop do while ie.readystate <> 4 stateString = stateString & " " & ie.readystate loop 在ie忙的时候做 stateString=stateString&&&cstr(即rea

我是vbscript新手,在阅读时发现一些代码如下

Do While ie.busy
stateString = stateString & " " & cstr(ie.readystate)
loop
do while ie.readystate <> 4
stateString = stateString & " " & ie.readystate
loop
在ie忙的时候做
stateString=stateString&&&cstr(即readystate)
环
请稍等,即readystate 4
stateString=stateString&&&ie.readystate
环
因此,任何人都可以告诉我繁忙的
属性
readystate
属性之间的区别。

来自:

迈克尔·哈里斯(MVP)写道:

仅仅根据过去在许多不同IE自动化场景中的经验,我观察到IE.Busy在确定文档的完全加载状态时不是100%可靠的。它出现了。忙碌会振荡真/假/真/。。。在某些情况下,.ReadyState最终到达4(完成)之前

这种振荡行为可能是当前版本中已修复的一个bug,但在我看来,对Busy的描述似乎比以前更好(至少我记得多年前读过它)。它只是简单地说明IE忙于导航或下载,并没有明确说明文档本身在构建DOM和页面在浏览器UI中实际呈现时所经历的各种状态之间的任何连接


使用.ReadyState而不是.Busy可以避免的问题是脚本试图在不完整的DOM中访问/操作时抛出的错误

谢谢分享你的经验。
        [...]
        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
    [...]