Safari and checking if page has loaded

Hey there, I’m looking for some help with AppleScript in Safari. Apple has some scripts that will take the frontmost MacCentral article and put it on your iPod in the new note reader. I’ve been adapting this to a local newspaper’s webpage to get headlines, and then to get each individual story and put it on the iPod.

Now if the page isnt loaded in Safari, you end up with problems, so I had to use dialogue boxes that asked you to click Ok once the page had loaded (this isnt fun when there are 20+ news stories). I’ve been looking all day for a way around this and finally found this page about telling AppleScript to wait for the page to be loaded before continuing. Alas, I do not know much about AppleScript, I’ve been learning as I go, but I cannot get the scripting they provide to work. I’m trying to put it inside a Tell Safari, and inside a ‘try’. If I check the syntax, I get an expected ‘error’ instead of the ‘page_loaded’ on the second line. If I check the syntax outside of my script, it works fine. So is there some reason I cant have it inside a try? Any suggestions?

Ok I think I just realized what I was doing wrong. The first line goes in your script and is calling a sub-routine which I have to put at the end of the script with all the other sub-routines that are called. Does this sound correct?

Yup! I was just getting ready to explain that very issue. :slight_smile: