How to open file links in Firefox 1.5 and above

Have you ever come across a URL that starts with file:// ? This usually happens on a corporate Intranet. Something like: file://na0/ogroups/everyone/vacation_policy.txt

These links won't open in Firefox. There used to be an easy work around but that has changed. The old way, opened up the browser or didn't. You allowed links or you didn't. Now it's on a site by site basis and requires you to edit (or create) your user.js file.

The user.js file is in your profile folder. If you don't know where your profile folder is, locate your profile folder. On Windows it is generally:
%AppData%\Mozilla\Firefox\Profiles\xxxxxxxx.default\, where xxxxxxxx is a random string of 8 characters. Just browse to C:\Documents and Settings\[User Name]\Application Data\Mozilla\Firefox\Profiles\ and the rest should be obvious.

user.js is just a text file. If you find one you can edit it in wordpad or notepad. If you don't find one, simply create one in notepad. Either way, you'll want the following lines in that file:
user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://www.example.com");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

The sites line can have multiple sites separated by spaces like:
user_pref("capability.policy.localfilelinks.sites", "http://www.example.com http://www.techlifeweb.com");

Also, be sure you get the protocol right. If you are trying to use this on a https site you'll need to specify https and not http.

More details on mozillazine.org
Tags: , , ,


8 Comments:

  • Thank goodness for this post. I searched the bejezus out of Firefox's support web site and found nothing using what I thought were common terms.

    So while I'm happy to find out the "why" of the problem, I'm confused by the solution provided. Specifically, why in the examples you've referenced http URLs when the problem is with file URIs? If the file is not on a web server, then what would the example look like? I've tried creating the user.js, and substituted in "file://~server name~" where appropriate, but without success.

    By Anonymous EJ, at 8:15 AM  

  • this solution doesn't work for me.
    i'm using bluefish 1.0.6 and want to preview created html files in firefox 2.0.
    firefox opens the url: file:///home/**** but then an annoying message box pops up, saying: this url is not valid and can't be loaded.

    By Anonymous michael singer, at 10:38 AM  

  • This helps! Thank you.

    Is there a way to get firefox to load the default file protocol handler instead of firefox opening a web page on the directory?

    For example, if I click on a file://///blah/trash.txt, is there a chance I can set something in user.js or some where else to tell firefox not to open a web page on trash.txt, but rather explorer on the the file trash.txt's parent blah?

    By Blogger Taylor, at 10:54 PM  

  • Taylor,
    Not that I can think of.

    By Blogger Scott, at 11:24 PM  

  • You can open file links from Firefox in Windows Exlorer with the help of the Launchy extension: http://gemal.dk/mozilla/launchy.html

    After you have installed the extension, right-click on a file link, select "Launchy..." and "Browse Link in Explorer"

    If you want to open the containing folder, you'll have to do some tweaking with Launchys configuration (launchy.xml), but it should be doable. (Hint:
    explorer.exe /select,"C:\trash.txt")

    By Blogger Peik, at 12:30 AM  

  • This didn't work for me (Firefox running on XP). I created the user.js file, but the links that normally work in IE7 would not work in Firefox. I also closed and restarted Firefox.

    By Anonymous Anonymous, at 7:21 AM  

  • If you are using the NoScript extension, open it's settings window (Extras->Addons->NoScript->Settings), select the "Advanced" tab, an in it the "Trusted" tab, to check the checkbox "Allow local links"!

    By Blogger Bernhard, at 8:23 AM  

  • Also not works for my. user.js is just ignored?

    About the confusion in above posts:

    You have an web page (http://example.com) which contains file links.

    If you read carefully: "localfilelinks.sites" says it ;-)

    By Blogger hfrmobile, at 1:17 AM  

Post a Comment

Links to this post:

Create a Link

<< Home