How Can One Tell When Safari Completes?
How Can One Tell When Safari Completes?
- Subject: How Can One Tell When Safari Completes?
- From: Gil Dawson via AppleScript-Users <email@hidden>
- Date: Mon, 10 Feb 2025 16:25:13 -0800
Hi--
Is there a way to tell when Safari completes loading a webpage?
I'm using do JavaScript ("document.readyState")...
set TargetLoc to "disney.com"
tell application "Safari" to ¬
tell its front document to ¬
open location TargetLoc
set SecondsToWait to 30 --Number of seconds to wait on Safari
repeat SecondsToWait times
tell application "Safari" to ¬
tell its front document to ¬
set ReadyState to ¬
do JavaScript ("document.readyState")
log "ReadyState=" & ReadyState
if ReadyState is "complete" then exit repeat ------------
-- delay 1 --no effect when I comment out the delay
end repeat
--> (*ReadyState=complete*)
... but, even without the delay, only one message gets logged.
My repeat loop seems to exit before the page actually appears.
My workaround is to insert plenty-long-enough delays in my code.
MacOS Sequoia 15.3 running Safari 18.3 on a MacBook Air M1, 2020
--Gil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden