Applescript:等待页面在 chrome 上加载 [英] Applescript : wait that the page is load on chrome

查看:31
本文介绍了Applescript:等待页面在 chrome 上加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tell application "Safari"
        repeat until (do JavaScript "document.readyState" in tab 2 of window 1) is "complete"
        end repeat
    end tell
end if

我怎样才能在 Chrome 中使用它?

how can I have this working with Chrome ?

推荐答案

你应该可以做到

tell application "Google Chrome"
repeat until (execute tab 1 of window 1 javascript "document.readyState" is "complete")
end repeat
    execute tab 1 of window 1 javascript "document.readyState"
end tell

但是您的页面可能会永远或长时间返回交互式".

but you may have pages that return "interactive" forever, or for a very long time.

只使用 AppleScript 应该是:

Doing it with just AppleScript is supposed to be:

tell application "Google Chrome"
    repeat until (loading of tab 1 of window 1 is false)
        1 + 1 --just an arbitary line
    end repeat
    loading of tab 1 of window 1 --this just returns final status
end tell

但是,说实话,我觉得这很可疑.我有一个页面,正文中的 html 非常简单(http://www.crgreen.com/boethos/boethos.html),它可以使用它,但是对于大多数页面(我已经尝试过 yahoo、macupdate、bbc 新闻、jedit.org 等)我没有得到loading = true", 曾经.可能有问题.

but, to tell you the truth, I find it suspicious. I have a page that's pretty bare html in the body (http://www.crgreen.com/boethos/boethos.html), and it works with that, but for most pages (I've tried yahoo, macupdate, bbc news, jedit.org, etc.) I'm not getting a "loading = true", ever. It may be buggy.

这篇关于Applescript:等待页面在 chrome 上加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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