Workaround for href=“file://///…” in Firefox

后端 未结 6 632
南方客
南方客 2020-11-27 06:43

On an intranet site, let\'s say I want to link to a file on a share using UNC, at:

\\\\servername\\foldername\\filename.rtf

It seems the co

相关标签:
6条回答
  • 2020-11-27 07:19

    I don't know if this will work, but give it a shot! Old article, but potentially still useful.

    http://www.techlifeweb.com/firefox/2006/07/how-to-open-file-links-in-firefox-15.html

    0 讨论(0)
  • 2020-11-27 07:36

    As it turns out, I was unaware that Firefox had this limitation/feature. I can sympathize with the feature, as it prevents a user from unwittingly accessing the local file system. Fortunately, there are useful alternatives that can provide a similar user experience while sticking to the HTTP protocol.

    One alternative to accessing content via UNC paths is to publish your content using the WebDAV protocol. Some content managements systems, such as MS SharePoint, use WebDAV to provide access to documents and pages. As far as the end-user experience is concerned, it looks and feels just like accessing network files with a UNC path; however, all file interactions are performed over HTTP.

    It might require a modest change in your file access philosophy, so I suggest you read about the WebDAV protocol, configuration, and permission management as it relates to your specific server technology.

    Here are a few links that may be helpful if you are interested in learning more about configuring and using WebDAV on a few leading HTTP servers:

    • Apache Module mod_dav
    • IIS 7.0 WebDAV Extension
    • Configuring WebDAV Server in IIS 7, 6, 5
    0 讨论(0)
  • 2020-11-27 07:36

    Add your own policy, open configuration "about:config" in the location bar and add three new entries:

    • capability.policy.policynames MyPolicy
    • capability.policy.MyPolicy.sites http://localhost
    • capability.policy.MyPolicy.checkloaduri.enabled allAccess

    Replace http://localhost with your website.
    Works with Firefox 70.0.

    0 讨论(0)
  • 2020-11-27 07:43

    Browsers like Firefox refuse to open the file:// link when the parent HTML page itself is served using a different protocol like http://.

    Your best bet is to configure your webserver to provide the network mapped file as a web resource so that it can be accessed by http:// from the same server instead of by file://.

    Since it's unclear which webserver you're using, I can't go in detail as to how to achieve this.

    0 讨论(0)
  • 2020-11-27 07:44

    In Firefox to Open File:\\\\\yourFileServer\docs\doc.txt for example you need to turn on some options in Firefox configuration:

    user_pref("capability.policy.policynames", "localfilelinks");
    user_pref("capability.policy.localfilelinks.sites", "http://yourServer1.companyname.com http://yourServer2.companyname.com");
    user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
    
    0 讨论(0)
  • 2020-11-27 07:46

    This question has been asked at least twice before, but I was unable to find those posts before posting my own (sorry):

    Open a direct file on the hard drive from firefox (file:///)

    Firefox Links to local or network pages do not work

    Here is a summary of answers from all three posts:

    • Use WebDAV — this is the best solution for me, although much more involved than I had anticipated.
    • Use http:// instead of file:///// — this will serve up a copy of the document that the user cannot edit and save.
    • Edit user.js on the client as described here — this worked for me in Firefox 3.6.15, but without access to client machines, it's not a solution.
    • In Firefox, use about:config, change the Security.fileuri.strict_origin_policy setting to false — this doesn't work for me in 3.6.15. Other users on [SO] have also reported that it doesn't work.
    • Use the locallinks Firefox extension — this sets the Security.fileuri.strict_origin_policy to true for you, and appears to have no other effect.
    • Read the file server-side and send it as the response — this presents the same problem as simply configuring your web server to use http://.
    0 讨论(0)
提交回复
热议问题