Internet Explorer 自动化繁忙 v/s readystate 属性 [英] Internet explorer automation busy v/s readystate property

查看:28
本文介绍了Internet Explorer 自动化繁忙 v/s readystate 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

那么任何人都可以让我知道繁忙的 propertyreadystate 属性之间有什么区别.

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

推荐答案

来自 这里:

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

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
    [...]

仅根据过去在许多不同 IE 自动化场景中的经验,我观察到 IE.Busy 在确定文档的完全加载状态时并不是 100% 可靠.在 .ReadyState 最终到达 4(完成)之前,似乎 .Busy 会在某些情况下摆动 true/false/true/....

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).

这种振荡行为可能是当前版本中已修复的错误,但在我看来更有可能的是 Busy 的描述比以前更好(至少我记得阅读许多年前).它只是说明 IE 正忙于导航或下载,并没有明确说明与文档本身在构建 DOM 和实际在浏览器 UI 中呈现页面时经历的各种状态的任何联系.

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.

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

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

这篇关于Internet Explorer 自动化繁忙 v/s readystate 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆