【发布时间】:2014-04-20 13:04:34
【问题描述】:
我的 Applescript 在 Safari 中(偶尔)遇到此错误。
Result:
error "Safari got an error: Can’t get document \"DOC TITLE\"."
number -1728 from document "DOC TITLE"
我认为这是因为页面没有加载,但我有一个 Javascript 在继续之前检查“完成”,还有一个 try 语句可以在出错时再延迟一秒。
不过,我仍然遇到这个问题。这似乎是相当随机的。
有什么建议吗?
Applescript(整个 Tell 语句):
tell application "Safari"
set the URL of the front document to searchURL
delay 1
repeat
if (do JavaScript "document.readyState" in document 1) is "complete" then exit repeat
delay 1.5 -- wait a second before checking again
end repeat
try
set doc to document "DOC TITLE"
on error
delay 1
set doc to document "DOC TITLE"
end try
set theSource to source of doc
set t to theSource
end tell
【问题讨论】:
标签: javascript excel safari applescript applescript-objc