I just found out that there was a do JavaScript command in Apple Script, so.... How do I get JavaScript to visit a URL in the active web browser window? The following opens in a new window, but I want it to open in the current window and then close it after 2 seconds (and pause for one): Code (Text): tell application "Safari" activate do JavaScript "window.open('http://www.aol.com')" in document 1 delay 2 tell application "System Events" tell process "Safari" delay 2 keystroke "w" using {command down} delay 1 end tell end tell end tell
Thanks Ricky! I'd +Rep but I have to +rep like 4 other people before +repping you again. --- Could I make javascript go to multiple pages or would I have to do something like this: Code (Text): delay x do JavaScript "document.location.href = 'http://www.page1.com/';" in document 1 delay x do JavaScript "document.location.href = 'http://www.page2.com/';" in document 1 delay x ? Thanks Ricky!!!!!
If you mean opening multiple tabs or browsers, that isn't how it's done.. If you mean visiting one page, waiting, then visiting another and so on: I think that's how it's done.. but I'm not fantastic with javascript.