• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How Can One Tell When Safari Completes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Next by Date: Re: How Can One Tell When Safari Completes?
  • Next by thread: Re: How Can One Tell When Safari Completes?
  • Index(es):
    • Date
    • Thread