# Opening links to local files file://

**URL:** https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449
**Category:** Development
**Created:** [June 16, 2017, 11:13am UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449 "2017-06-16T11:13:59Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)
#### Post date: [June 16, 2017, 11:13am UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/1 "2017-06-16T11:13:59Z")

</div>

Hello,  
I’m developing [Group Speed Dial](https://addons.mozilla.org/en-US/firefox/addon/groupspeeddial/) using web-extension API and I’m getting feature requests to support file:// protocol.  
Some people want to access their locally stored .html pages from speed-dial addon.

However there is some security restriction that prevents opening any link pointing to “file:///”.

**Is there a way to get over this restriction? Now or in the future - by requesting maybe a new security API for web-extension?** If there is no solution yet, can somebody tell me what would be the best way to request this kind of feature?

In Chrome local files just works.

---

<div class="post-metadata">

### Author: ![NilkasG](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@NilkasG](https://discourse.mozilla.org/u/NilkasG)
#### Post date: [June 16, 2017, 12:16pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/2 "2017-06-16T12:16:41Z")

</div>

> [@juraj.masiar](#):
>
> In Chrome local files just works.

AFAIK in Chrome, the user has to set an extra checkbox in the add-on manager, which will only appear if the extension has set host permissions including `<all_urls>` or `file://`…

There is a function in the `.extension` or `.runtime` namespace that should tell you whether you have file system access or not. If that returns `false` in Firefox, I guess that is your answer, at least for now.

---

<div class="post-metadata">

### Author: ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)
#### Post date: [June 16, 2017, 12:25pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/3 "2017-06-16T12:25:34Z")

</div>

Sorry I was not aware of that, seems like locally loaded addons (during development) has this checkbox automatically checked.

---

<div class="post-metadata">

### Author: ![ericjung1](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ericjung1/32/15471_2.png) [@ericjung1](https://discourse.mozilla.org/u/ericjung1)
#### Post date: [June 19, 2017, 7:41am UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/4 "2017-06-19T07:41:40Z")

</div>

Juraj Masiar, can you please post a sample of the code that fails for you?

---

<div class="post-metadata">

### Author: ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)
#### Post date: [June 19, 2017, 5:49pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/5 "2017-06-19T17:49:45Z")

</div>

There are no errors, Firefox just won’t react on clicking on elements pointing to local files.  
For example:

```
<a id="dial_13" href="file:///C:/Users/Juraj/Desktop/simple.html">Click me</a>

```

will not open file “simple.html” from my desktop (if I copy the ‘href’ value into addressbar I can view the html file).  
I understand the security issue here but I believe the add-ons deserves this functionality.

There is also some article here about accessing files [https://wiki.mozilla.org/WebExtensions/Filesystem](https://wiki.mozilla.org/WebExtensions/Filesystem)

---

<div class="post-metadata">

### Author: ![ericjung1](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ericjung1/32/15471_2.png) [@ericjung1](https://discourse.mozilla.org/u/ericjung1)
#### Post date: [June 23, 2017, 1:40am UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/6 "2017-06-23T01:40:28Z")

</div>

Unfortunately, it’s not planned for Firefox 57, but may be available later. Even the article you linked to at [https://wiki.mozilla.org/WebExtensions/Filesystem](https://wiki.mozilla.org/WebExtensions/Filesystem) mentions at the very bottom “Firefox 57 / Not Planned / Access to file:// URLs or reading files without any explicit user input”

---

<div class="post-metadata">

### Author: ![MJG](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/mjg/32/17147_2.png) [@MJG](https://discourse.mozilla.org/u/MJG)
#### Post date: [October 24, 2017, 7:57am UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/7 "2017-10-24T07:57:08Z")

</div>

Hi there,

it’s unfortunate that this isn’t even possible on explicit user input or by requesting permissions.

I’m the author of the [LocalLink addon](https://addons.mozilla.org/de/firefox/addon/locallink/) which adds a context submenu to the page context menu so that users can open `file://` links contained in web pages. (Some bad content systems do this so that users rely on it.) Note that this requries explicit interactions, I’m not circumventing same-origin policy for “ordinary link clicks”.

In the XUL version of my addon, I use `window.loadURI(uri, null, null)`, `openNewTabWith(uri, null, null, event)` and `openNewWindowWith(uri, null, null)` to open those uris irrespective of `checkloaduri`.

I ported the context menu and such to webextensions now, but `browser.tabs.update()` and `window.open()` called from a background script are subject to the same-origin restrictions, no loading of `file://` uris

requesting `"file://*/"` permissions in `manifest.json` does not help either. MDN docu suggests `"content_security_policy": "script-src 'self'; object-src 'self'; navigation-to 'filesystem:'"` but my Firefox 56 does not know `navigation-to`, and I don’t think Firefox 57 does.

Entering `file://` uris in the address bar directly works, of course. Is there any way to (request a permission to be able to) to do this from a webextension? I.e., based upon user input, update a tab or create a new one that navigates to a given `file://` uri?

Michael

---

<div class="post-metadata">

### Author: ![itsame](https://avatars.discourse-cdn.com/v4/letter/i/5daacb/32.png) [@itsame](https://discourse.mozilla.org/u/itsame)
#### Post date: [August 2, 2021, 3:06pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/8 "2021-08-02T15:06:01Z")

</div>

Has this been fixed?

---

<div class="post-metadata">

### Author: ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)
#### Post date: [August 2, 2021, 3:11pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/9 "2021-08-02T15:11:37Z")

</div>

Actually there is a workaround I didn’t know about back then that fixes this for a specific addon. See this comment for specific instructions:

> <https://github.com/fastaddons/GroupSpeedDial/issues/36#issuecomment-788283828>
>
> \*\*Describe the bug\*\*
> I have HTML documentation on my local machine that I want …to open with a dial. I can paste the URL into the browser and it opens file, but if I create a dial and click on it nothing happens, it is as if the dials is non-clickable. If I right click on the dial and copy the URL and paste it manually into the browser, it opens.
> 
> \*\*Steps To Reproduce\*\*
> 1. Create or copy an HTML file to your local filesystem. Verify you can open it in a browser.
> 2. Create a dial with a link to the HTML file. (URL will be "file:///path/to/file.html")
> 3. See that the dial is non-responsive and doesn't open the page.
> 
> \*\*Expected behavior\*\*
> Dial should open the link.
> 
> \*\*Device info:\*\*
> - operating system: Linux (Manjaro, up to date)
> - Browser and version: Firefox 86.0
> - GroupSpeedDial version: 15.5
> 
> 
> \*\*Additional info\*\*
> Nothing else.

---

<div class="post-metadata">

### Author: ![Kate11223144](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@Kate11223144](https://discourse.mozilla.org/u/Kate11223144)
#### Post date: [August 2, 2021, 11:07pm UTC](https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/10 "2021-08-02T23:07:07Z")

</div>

I have been trying to load a PDF with the documentation provided , the pdf loads up fine but some of the layers they dont load up properly . I’ve tried templates from a few websites . e.g [teardrop flags](https://www.vividads.com.au/collections/best-seller/products/teardrop-banners-flags) these are showing errors .

any tips ?
