33

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.

3
  • 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
    Commented Feb 23, 2014 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
    Commented Feb 23, 2014 at 14:51
  • I have updated my answer
    – markhunte
    Commented Feb 23, 2014 at 18:11

13 Answers 13

23

Finicky - Always open the right browser

Is a free and open-source tool for that with a bunch of different settings and rules, it can:

  • Write rules to open urls in any browser
  • Rewrite and replace parts of urls before opening them
  • Automatically resolves the destination url from short url providers

Regarding your direct question, here is settings:

/**
 * Save as ~/.finicky.js
 */
module.exports = {
    defaultBrowser: "Google Chrome",
    handlers: [
        {
            match: finicky.matchHostnames(["your_specific_url_to_open_in_Firefox"]),
            browser: "Firefox"
        }
    ]
};

That's it! Just start this plugin and it will handle all the redirections for you.

For more examples, see the Finicky github page

1
  • Still works flawlessly 5 years later. Commented Aug 16 at 13:47
18

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!

2
  • 1
    At least for macOS 12.1 this might not work as expected. When the given browser is not the default browser and it is not open yet, the command opens the URL in both the given and the default browser at the same time. Hacky workaround which opens the (non-default) browser before opening the URL: open -a safari; sleep 2; open -a safari http://apple.stackexchange.com. It might be necessary to adjust the wait time depending on the speed of the system.
    – Wumms
    Commented Dec 22, 2021 at 10:14
  • 1
    @Wumms - I think the issue is more specific. When Safari isn't the default browser and is not open yet, the command to open Safari also opens the default browser. I am not seeing this issue when opening any other browsers. Commented Feb 9, 2022 at 9:47
10

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.

9
  • 6
    Note that Choosy is behind a paywall. Commented Jan 3, 2017 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! Commented Nov 28, 2017 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. Commented Jan 30, 2018 at 0:58
  • 1
    A free and open source replacement… which requires you to edit JSON in order to set up rules. I'm sticking with Choosy, thanks.
    – TJ Luoma
    Commented Dec 30, 2019 at 17:06
  • 1
    @skywinder a) Windows now has a Linux sub-system, so it has plenty of command-line tools; and b) I've been writing shell scripts since 1991 on NeXT, so I'm hardly averse to the command-line. What I am averse to is people who will choose a lesser tool they claim is "just as good" because it's free. Using a text file for configuration on a Mac is just developer laziness.
    – TJ Luoma
    Commented Jan 2, 2020 at 2:46
2

You can use Browserosaurus check this software, this is free for a lifetime. This is exactly like choosy but free.

Check this link for Browserosaurus

Advantage is it is open source. Here is the link

1

Force URL link to open with a specific browser

There's now a free and portable (Linux, Mac & Windows) way to do this across all major browsers and most importantly, BETWEEN browsers.

For example, I use Opera for a few pinned communication tabs: Gmail, G Calendar, WhatApp, etc... I use Firefox for everything else, and Chrome for a few sites that just never work in Firefox.

Andy Portman's open source "Open In" extensions solve this for every major browser.

https://add0n.com/open-in.html

Step 1: Browser Extension(s)

In Firefox I installed:

For Opera I installed:

Note that Andy Portman has tons of other versions depending on which browser's you use.

See his whole list at:

https://add0n.com/open-in.html#faq1

enter image description here

Step 2: Native Client (to enable your browser to open other browsers)

Grab the Linux, Mac or Windows client for your platform and install it

https://github.com/andy-portmen/native-client/releases

Step 3: Customize the rules to decide when the browser your using should direct requests to another browser.

For example, in Firefox I'm using two extensions. 1 to send some links to Chrome 1 to send some links to Opera

For Firefox "Open in Chrome" I just set:

enter image description here

For Firefox "Open in Opera" I set:

enter image description here

For Opera "Open in Firefox" I set:

enter image description here

Note that I also set "Reverse Mode" here so the domains that I don't specify will automatically be redirected to Firefox.

DONE

Enjoy using the browser you want on the site you want.

Please post a reply and an upvote if this helps you.

1

You could use my free Velja app for this. It lets you easily create rules to make certain URLs open in a specific browser.

Open the app settings, go to the “Rules” tab, click "+", select "Firefox" in the "Open in" dropdown, add a URL matcher that matches the URL you want to open in Firefox, and then click "Save".

1
  • 1
    How would the app solve the specific problem described in the question?
    – nohillside
    Commented Mar 30 at 13:42
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
3
  • 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
    Commented Feb 23, 2014 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
    Commented Feb 23, 2014 at 17:26
  • @NReilingh see the update which may work for you.
    – markhunte
    Commented Feb 23, 2014 at 18:11
0

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.

3
  • @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
    Commented Feb 23, 2014 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
    Commented Feb 23, 2014 at 22:08
  • I thought it should have worked. Must be my Mac being a pain.. Cheers
    – markhunte
    Commented Feb 24, 2014 at 14:13
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
0

Note: I am about to recommend my app which is available on the Mac App Store. Here is the download link


You can use Linko

Linko dashboard

Features

  • Easy to use hence good for someone who wants to quickly set up a few basic rules
  • Has an inbuilt Rule tester to visualize the rule matching functionality

How is it different from the solutions mentions above?

It is much easy to use as compared to Choosy. Choosy is a powerful tool and is loaded with features. But for someone looking for a simple and easy solution, Linko would be the right tool.

Finicky also does the job well, but few people have mentioned that editing a config file might be cumbersome for some users.

So all in all, Linko is for someone who is looking for a basic and easy interface with no advanced features and no config file to edit.

1
  • Looks interesting but it's a little expensive for how many times we'd use it. Commented Dec 30, 2021 at 15:27
0

Follow the instructions here: https://discussions.apple.com/thread/253544940 which produce a quick action in automator to convert .webloc files to .url files. Unfortunately, as of 13.1 Ventura, .url files are always opened in Safari so an additional modification is required. Save your quick action in automator as webloc2html and replace the bash script with the following:

for p in "$@"; do
    echo "Found webloc: $p"                        ## $p: ./some/dir/link.webloc
    DIR=$(dirname "${p}")                          ##     ./some/dir
    FILENAME=$(basename "${p}")                    ##     link.webloc
    FILENAME_BASE=$(basename "$FILENAME" .webloc)  ##     link

    TEMP_FILE="$DIR/temp_link.html.$$.tmp"         ## ./some/dir/temp_link.url.2342343.tmp
    FILEPATH_url="${DIR}/${FILENAME_BASE}.html"    ## ./some/dir/link.url

    ## remove any "._XY" files - AppleDouble encoded Macintosh file
    ## see: http://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats

    dot_clean -m "$DIR"

    LINK=`plutil -convert xml1 -o - "$p" | grep "string" | sed "s/<string>//" | sed "s/<\/string>//" | sed "s/  //"`
    echo " - Link is: $LINK"
    echo " - Create HTML forwarding file"

    ##echo "[InternetShortcut]" > "${TEMP_FILE}"
    ##echo "URL=$LINK" >> "${TEMP_FILE}"

    echo "<!DOCTYPE html>"                                             > "${TEMP_FILE}"
    echo "<html>"                                                     >> "${TEMP_FILE}"
    echo "<head>"                                                     >> "${TEMP_FILE}"
    echo "<title>webloc2html</title>"                                 >> "${TEMP_FILE}"
    echo "<meta http-equiv=\"refresh\" content=\"0; url=${LINK}\" />" >> "${TEMP_FILE}"
    echo "</head>"                                                    >> "${TEMP_FILE}"
    echo "</html>"                                                    >> "${TEMP_FILE}"

    mv "${TEMP_FILE}" "${FILEPATH_url}"
done

echo "all done."
## EOF.

The workflow is to drag a url from the browser address bar to the desktop or a folder to create a .webloc file. Then right click on the .webloc and choose Quick Actions > webloc2html from the context menu. (Quick actions can also appear in a panel in Finder when you click on a file.) The quick action will run and place a .html file in the same location as the .webloc file. The .html will open in your default browser. You can then dispatch the .html to the particular browser you prefer for them with something like Browser Ninja.

You must log in to answer this question.

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