Open URL in New Safari Tab
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