How do I instruct Applescript to open a new Firefox window with a link?

Viewed 19897

My code looks like this

tell application "Firefox"
 open location "http://rubyquicktips.tumblr.com/"
end tell

But if I have Firefox open, the link will open in a new tab. But I want the link to open in a new Firefox window. How can I accomplish that?

6 Answers

this works, but opens your welcome site in first tab...

tell application "Firefox" to activate
tell application "System Events" to keystroke "n" using command down
delay 3
tell application "Firefox"
    open location "http://rubyquicktips.tumblr.com/"
end tell

solutions which "activate" are wrong because they switch desktop

do shell script "open -n -a Firefox"

I use the below simple shell script to open multiple firefox pages in different tabs and it works for me. May be you need to adjust the sleep time little bit.

Steps:

  1. Go to Automator

  2. Select: Application

  3. Click on choose

  4. Search Run Shell Script

  5. Click and drag it to the right hand window

  6. In Shell select /bin/bash

  7. In Pass input: select as arguments

  8. Paste the below code

    #!/bin/bash
    
    open -a Firefox https://stackoverflow.com
    sleep 0.5
    open -a Firefox https://apple.com
    sleep 0.5
    open -a Firefox https://google.com
    
  9. Command + S to save it

  10. Give a name and location to save.

  11. Choose File format: Application

  12. Save

  13. Add it in your dock (applicable for MAC os) and enjoy (applicable for every os :)!!

Related