osx - How can I use AppleScript to open a new Safari window on the current desktop space?

07
2014-07
  • Josiah Sprague

    I need to open a new Safari window in the current desktop space using AppleScript. NOT move to another space which has Safari running and then open another Safari window.

    Of course, if Safari is not running then it should start a new Safari process in the current space.

  • Answers
  • kevin

    You can put the following code into the apple script editor and save the file as application.

    tell application "Safari"
        make new document
        activate
    end tell
    

    Now you can simply double click on the script and you will be able to open a new safari window inside of the current "active" space, even though you may have another safari window open in another desktop space. It will not switch.


  • Related Question

    osx - Make Safari open new links in existing windows as a tab, rather than a new window
  • David Pearce

    When using NewsFire for checking my feeds and I click the title to read the full article, it opens it in a new window in the background in Safari. How can I make it open the articles in a new tab in the existing Safari window?

    I have looked in the settings for both Safari and NewsFire, but I cannot find anything that would help me. I am guessing this is a problem with Safari, not NewsFire.


  • Related Answers
  • 8088

    In Safari's preferences under "General" at the bottom is an item that says:

    Open links from applications: in a new window or in a new tab in the current window

    Make sure the radio button beside new tab in a current window is selected.

    Preferences Window

  • David Pearce

    In Terminal (Applications/Utilities/Terminal), type in and run:

    defaults write com.apple.Safari TargetedClicksCreateTabs -bool true
    

    Then restart Safari.