Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Open URL in New Safari Tab

I would like to have Safari navigate to a specific URL in a new tab. I'm a noobie in AppleScript but I've been able to cobble the following together.

set theURL to "https://www.someURL"

tell application "Safari"
activate
set currentTab to current tab of window 1
set URL of document 1 to theURL
end tell

It works when Safari isn't running or when a Safari window is open but otherwise I get a "Safari got an error: Can’t get document 1. Invalid index." error. How do I correct my code?

Also how to I format these posts so that my code looks like code, and

Is there a good AppleScript tutorial available somewhere?

imac, Mac OS X (10.6.6), None

Posted on Mar 3, 2011 2:14 PM

Reply
Question marked as Best reply

Posted on Mar 3, 2011 2:31 PM

Try:

set theURL to "http://www.apple.com"
tell application "Safari" to open location theURL

Also how to I format these posts so that my code looks like code,


....
....
17 replies

Open URL in New Safari Tab

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.