• 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
Wait for Load with PDF download in Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wait for Load with PDF download in Safari


  • Subject: Wait for Load with PDF download in Safari
  • From: Adam Morris <email@hidden>
  • Date: Sun, 2 Aug 2009 09:01:10 -0400

Hi all,

I have a program that downloads the PDFs provided from a webpage from my university (for copying automatically to my Kindle). I've been using the delay command to make it wait for the download and has worked fine, but I've always wanted a script function that would loop until Safari's front page stopped loading.  This is what I have been using:

on waitforload()
tell application "Safari"
delay 1
repeat
set thisDoc to front document
if (do _javascript_ "document.readyState" in thisDoc) is "complete" then exit repeat
delay 2 -- wait a second before checking again
end repeat
delay 1
end tell
end waitforload

This only works for the loading of the HTML/CSS/DOM side, but doesn't reflect the fact that, in some cases (including mine) the document.readyState shows "complete" even though the document itself actually downloading a PDF.

I was wondering if anyone has found a surefire way to write this function that works in every case conceivable? (For Safari 4 at least)  Maybe file a bug with Apple, saying scripters ought to be able to detect this with a call to, say, ready state of document?


 _______________________________________________
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

  • Follow-Ups:
    • Re: Wait for Load with PDF download in Safari
      • From: Matt Deatherage <email@hidden>
    • Re: Wait for Load with PDF download in Safari
      • From: "email@hidden" <email@hidden>
    • Re: Wait for Load with PDF download in Safari
      • From: Skeeve <email@hidden>
  • Prev by Date: Re: List all the app-defined keywords?
  • Next by Date: Re: Wait for Load with PDF download in Safari
  • Previous by thread: Auto: AppleScript-Users Digest, Vol 6, Issue 349
  • Next by thread: Re: Wait for Load with PDF download in Safari
  • Index(es):
    • Date
    • Thread