Applescript + Safari open URL

Discussion in 'Mac Programming' started by Iceman332k1, May 14, 2010.

  1. Iceman332k1 macrumors newbie

    Dec 15, 2009
    I need to make an Applescript that opens Safari (or switches to it if it's already open) and then opens a webpage. Just something basic like or I want to bind it to a tap on my new magic mouse, but for the life of me I am unable to find a script online that I can get to work. Again, I do not need it to do anything after opening the webpage.

  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    tell application "Safari" to open location ""
  3. Iceman332k1 thread starter macrumors newbie

    Dec 15, 2009

    I'm sorry, but could you type it out as it should read as an applet? I'm honestly having trouble and this is my first attempt at applescripts
  4. TuffLuffJimmy macrumors G3


    Apr 6, 2007
    Portland, OR
    Open AppleScript Utility (It's somewhere in the Applications folder I believe).

    Type the previous code with replaced with whatever URL you want to go to.

    Save it as an Application.

    Now you have an Application.

    Double click the application to go to the URL.
  5. rsrs922 macrumors newbie

    May 31, 2012

    If you don't want it to always open in safari, you can just remove the "tell application safari part"
    Make sure the browser you want to open it in is your default browser. Then in AppleScript, type:
    open location ""
    You can change the url to whatever you want.
    Then press "command shift s" to save as and select application. Now when you open the app, the url will open.
    Hope this helps!

Share This Page