Making File URLs Work Again in Firefox
Published on 4 Apr 2020 · Filed in Explanation · 283 words (estimated 2 minutes to read)At some point in the last year or so—I don’t know exactly when it happened—Firefox, along with most of the other major browsers, stopped working with file:// URLs. This is a shame, because I like using Markdown for presentations (at least, when it’s a presentation where I don’t need to collaborate with others). However, using this sort of approach generally requires support for file:// URLs (or requires running a local web server). In this post, I’ll show you how to make file:// URLs work again in Firefox.
I tested this procedure using Firefox 74 on Ubuntu, but it should work on any platform on which Firefox is supported. Note that the locations of the user.js file will vary from OS to OS; see this MozillaZine Knowledge Base entry for more details.
Here’s the process I followed:
-
Create the
user.jsfile (it doesn’t exist by default) in the correct location for your Firefox profile. (Refer to the MozillaZine KB article linked above for exactly where that is on your OS.) -
In the
user.js, add these entries:// Allow file:// links user_pref("capability.policy.policynames", "localfilelinks"); user_pref("capability.policy.localfilelinks.sites", "file://"); user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess"); -
In your Firefox configuration (accessible using
about:configin a Firefox tab), change the value ofprivacy.file_unique_originfromtruetofalse. -
Restart Firefox.
After you restart Firefox, you should be able to use file:// URLs, but only from local HTML files on your system (as specified by the second line you added in step 2). It’s possible this may expose an unknown security flaw or weakness that I haven’t foreseen, so keep that in mind.
If you’re a fan of Markdown-based presentations displayed using your browser, they should work again.
Hit me on Twitter if you have questions. Thanks!