7

I've created a URL link in my dock, however, the link only opens with the default browser. I have safari, Firefox, and chrome (latest being the default) installed in my machine. I'm wondering if someone knows how to default the link to open with Firefox instead of Chrome but still keeping chrome as the default browser. Note: I'm running Mavericks in my MacBook Pro.

  • You could create a script which opens a certain browser and navigating to the URL you'd like to see. You have to set the script in the Dock instead of the current URL-link you have. – Rob Feb 23 '14 at 14:05
  • You cannot set the browser in a .url file. So, you need to write a script instead of the .url file in which you open a browser with your link. – NEO Feb 23 '14 at 14:51
  • I have updated my answer – markhunte Feb 23 '14 at 18:11
8

You could use the all powerful open command to achive this using a shell script / apple script. Not necessarily the nicest way, but that's the way I do it.

open http://apple.stackexchange.com -a Firefox.app 

would be the basic command to open this page in Firefox. You can easily wrap this in a nice to use apple script - let me know if you need to know how!

7

You can use Choosy and set the rules for the URL you’ve created in Dock. Not only does it work for the URL in the Dock, the rules also apply to all the links you open in Safari, Firefox, or Chrome. If you need a certain domain, or URL patterns to be opened in separate browser, then Choosy is the one you need.

  • Note that Choosy is behind a paywall. – ShadSterling Jan 3 '17 at 20:12
  • Thank you! I was about to ask a question very similar to OP, to which Choosy seems to be the absolute best tool for the job! – Fabio Bracht Nov 28 '17 at 17:17
  • This is an old answer but it's the one I was looking for. Choosy is great. Haven't found anything else that actually does what Choosy does. I personally use it to ensure links from a certain app always open in chrome even though my default browser is FireFox. – markquezada Jan 30 '18 at 0:58
1

I use the context menu on the URL file to open the site in any browser:

  • Right click and select the Info sheet
  • Beneath "Open With", select Other -> Show all Applications
  • Select the web browser of your choice

Now after you done with that, move it to Dock and it will do what you wanted.

  • @Buscar웃 Are you sure this works. This was one of the first things I tried but used the info window. But it did not work. The file kept opening in the default browser. just tried it again with the contextual menu, the same. – markhunte Feb 23 '14 at 22:04
  • Well I just tried it and it worked for me. Save the URL to the desktop first, modify it then move to the dock – Ruskes Feb 23 '14 at 22:08
  • I thought it should have worked. Must be my Mac being a pain.. Cheers – markhunte Feb 24 '14 at 14:13
0

Firefox (at least my version, 27.0.1) doesn't seem to support .url files, unfortunately.

So, what I did is made a .html file that redirects to the correct URL. This is all you need to put in the file, just a plain text document:

 <meta http-equiv="refresh" content="0;URL_GOES_HERE">

Replace URL_GOES_HERE with the URL you want, including http:// or https://.

Select it in Finder, Command ⌘+I to Get Info, and scroll down to Open With, where it should have a popup menu that shows Chrome. Change that to Firefox. Above that it should say Name & Extension; if it has something like .html.txt you can change it to .html.

0

Here is an Applescript that you can save as an Application and access from your dock like any normal application.


What it does

It allows you to dynamically change the URL to open if you ned to.

This means you do not have to hard code the URL into the application.

Once a URL is set you just need to click the application at any time in the Dock to open it in FireFox. Or open the App as normal from finder.

You can change the URL easily any time by following step 1 below.


Step 1, Setting the Apps URL:

Copy an URL to the clipboard and click the app in the dock.

It will check if the clipboard starts with "http:" if it does it will mean you want to set the url for the app to open in firefox.

A display dialog will open to confirm this and for you to make any adjustments to the URL.

enter image description here

It will then set the store URL and clear the clipboard.


Step 2, Opening The URL once an URL has been set:

Now any time you click the App in the Dock it will open the URL in firefox.


To change the URL Repeat step 1.


The Applescript

(* stored url *)
property theUrl : ""

on run

    (* check if the clipboard has an http url*)
    set fromClip to the clipboard as string

    if fromClip starts with "http:" or fromClip starts with "https:" then
        (* Theclipboard has an http url so this means we want to update the apps url to open in firefox *)

        (* Confirm this is what we want to do, and we can make adjustments to the url*)
        display dialog "Set new URL to " default answer fromClip buttons {"Cancel", "OK"} default button 1


        copy the result as list to {button_pressed, text_returned}
        if button_pressed is "OK" then
            (* Set the url to the stored property*)
            set theUrl to text_returned

            (* Clear the clipboard*)
            set the clipboard to ""
        end if


    else
        (* check if the clipboard DID NOT start with http url*)
        if theUrl is not "" then
            (* This means   we want to open the current url in firefox *)
            do shell script "open " & quoted form of theUrl & " -b org.mozilla.firefox"
        end if

    end if


end run

Note:

This is written in OS X 10.9

Where it seems the {text_returned, button_pressed} list is reversed to {button_pressed, text_returned}


UPDATE Second idea.

To possibly satisfy any one who does not want to use the clipboard. And wants to stick to using a file (webloc)

This Applescript when saved as an Application and in the Dock.

Will when first run ask for a folder where the single webloc file is stored.

The folder should only ever have one file inside.

When run any time after it will open the file or any other file you place in the folder.

If it cannot find a file in the folder or the folder it's self when you run the app to open the url it will warn you and offer you the choice to reset the folder.

property theUrl : ""

on run

    if theUrl is not "" then
        try
            tell application "System Events" to set chosenFile to POSIX path of (file 1 of theUrl) whose visible is true

            do shell script "open " & quoted form of chosenFile & " -b org.mozilla.firefox"
        on error errm

            display dialog "ERROR : The URL Folder may be empty or not exist" with icon 0 buttons {"Reset Folder", "OK"} default button 1 giving up after 5
            copy the result as list to {button_pressed, text_returned}
            if button_pressed is "Reset Folder" then
                set theUrl to (choose folder)
            end if
        end try
    else

        set theUrl to (choose folder)
    end if


end run
  • 2
    This seems excessive and over-engineered to me. The dock icon will not work as expected any time you happen to have a URL copied to the clipboard, which, at least for me, is quite often (9 of my past 15 clipboard contents were URLs). Also this won't work for https. – NReilingh Feb 23 '14 at 17:15
  • @NReilingh Good point on the Https. Which I have now adjusted for. But I do not agree with you on you other point. The Dock icon will work as expected because of the behaviour given to it and it's expected behaviour is explained. But for you this may not work because how useful an App is is subjective to your needs and situation. Other solutions may work for you that include hard coding the URL. – markhunte Feb 23 '14 at 17:26
  • @NReilingh see the update which may work for you. – markhunte Feb 23 '14 at 18:11
0

I solved this with a much simpler AppleScript, and posted the solution in detail at https://apple.stackexchange.com/a/267324/71739. In summary, create an AppleScript application with this code:

tell application "Safari" to open location "https://apple.stackexchange.com/"

But keep a copy of the Script file, because you can't reopen Applications in the Script Editor.

0
tell application "Google Chrome"
    if it is running then
        make new window
        open location "http://wdmycloud.local"
        delay 1
        activate
    else
        activate
        open location "http://wdmycloud.local"
        delay 1
        activate
    end if
end tell

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .