View Full Version : Applescript: closing a Safari window when it reaches a certain URL?

01-13-2006, 04:49 PM
I want to make an applescript that launches/activates Safari, makes a new window, goes to a URL in the window, and then closes the window WHEN the window reaches a certain other URL.

So far I have:

tell application "Safari"
make new document at the beginning of documents
set the URL of the front document to "http://INITIALWEBPAGE/"
end tell

I just have to figure out how to get it to close the window when it gets to a second, specified webpage (because the user will be surfing through some stuff that will eventually take him/her there). Thanks!

mark hunte
01-13-2006, 06:03 PM
You could have the script run as a app.

And use the : on idle handler, to have the script check the Document 1
of safari every what ever.
If it finds a match to your second site then it quits Safari.