5

Having file:// links within a website e.g. http://localhost will not open because of security reason.

In IE and Firefox it's possible to allow such access either in the "Trusted Sites" & "Local Intranet" from IE or to configure a policy in Firefox:

enter image description here

I can't figure out a way in Chrome or Edge.
Searching the web I came across solutions like the --allow-file-access-from-files flag, but that does not work in Chrome 77.0.
Also there are some extensions which enable that behavior: Enable local file links

I believe there must be some similar way with policies like in Firefox?

EDIT: update 22.03.2021

Chrome Version 89.0.4389.90
Edge Version 89.0.774.57

Result:

Not allowed to load local resource: file:///D:/temp/demo.pdf

Demo HTML:

<html>
<body>
    <a href="file://fileserver/demo.pdf">file://fileserver/demo.pdf</a><br/>
    <a href="file:///d:/temp/demo.pdf">file:///d:/temp/demo.pdf</a> extra slash according to https://en.wikipedia.org/wiki/File_URI_scheme
</body>
</html>
flavio.donze
  • 7,432
  • 9
  • 58
  • 91

2 Answers2

2

[Update 2022]
As mentioned by flavio.donze, since Edge v95 there is a new policy:

Allow intranet zone file URL links from Microsoft Edge to open in Windows File Explorer

If you enable this policy, intranet zone file URL links originating from intranet zone HTTPS pages will open Windows File Explorer for that file or directory.

So to get this to work, you have to use HTTPS and specify the site as a site being in the intranet zone.

[Outdated - old answer]
Yes, there is a similar policy in Edge (v88 or later), but it only works in conjunction with IEMode:

When a file:// URL is requested to launch in Internet Explorer mode, the file extension of the URL must be present in this list in order for the URL to be allowed to launch in Internet Explorer mode. A URL which is blocked from opening in Internet Explorer mode will instead open in Edge mode.

This policy controls the visibility of the 'Open link in new Internet Explorer mode tab' option on the context menu for file:// links.

[Other browsers]
The alternatives are, as you already stated above in your question:

kapsiR
  • 2,720
  • 28
  • 36
0

There is a new GPO introduced in Edge 95: IntranetFileLinksEnabled

But as stated here, it might only solve the problem for some scenarios:
https://stackoverflow.com/questions/69708560/edge-policy-intranetfilelinksenabled-enabled-does-not-open-file

Because only the windows-explorer is opened and not the actual file: enter image description here

<a href="file://power/share/demo.txt">file://power/share/demo.txt</a><br/>
<a href="file://power/share/demo.docx">file://power/share/demo.docx</a><br/>
<a href="file://power/share/demo.pdf">file://power/share/demo.pdf</a><br/>
<a href="file://power/share/demo.html">file://power/share/demo.html</a><br/>

This setting allows file URL links to intranet zone files from intranet zone HTTPS websites to open Windows File Explorer for that file or directory.

If you enable this policy, intranet zone file URL links originating from intranet zone HTTPS pages will open Windows File Explorer for that file or directory.

If you disable or don't configure this policy, file URL links will not open.

flavio.donze
  • 7,432
  • 9
  • 58
  • 91