如何打开本地文件的href? [英] How to open href to local file?

查看:449
本文介绍了如何打开本地文件的href?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是代码

 < a href =file:///\\10.0.4.4\001-100 Design Projects \> log<一个> 

如果我尝试通过浏览器网址将此地址设为

  file:///\\10.0.4.4\001-100 Design Projects\ 

打开它,但是它不起作用。我提醒,它可以在铬合适的。
我想知道解决这个问题的方法。



在此先感谢

解决方案

看看这篇文章的Firefox的特定限制: href =file://///...的解决方法在Firefox中



以下是答案摘要:


  • 使用WebDAV - 这对我来说是最好的解决方案,虽然比我预期的要复杂得多。

  • 使用http://而不是file:///// - 用户无法编辑和保存的文档的副本。

  • 在客户端上编辑user.js,如 http://www.techlifeweb.com/firefox/2006/07/how-to- open-file-links-in-firefox-15.html - 这个在Firefox 3.6.15中可以工作,但是没有访问客户端的机器,这不是一个解决方案。

  • 在Firefox中,使用about:config,将 Security.fileuri.strict_origin_policy 设置更改为false - 在3.6.15中这对我不起作用。 SO上的其他用户也报告说它不起作用。
  • 使用locallinks Firefox扩展 - 这显然只是设置 Security.fileuri.strict_origin_policy 为真,并且看起来没有任何作用。
  • 读取服务器端的文件并将其作为响应发送 - 这表现出与配置Web服务器使用http://。






Firefox具有此限制/功能。我可以同情这个功能,因为它可以防止用户无意中访问本地文件系统。幸运的是,有一些有用的选择可以提供类似的用户体验,同时坚持使用HTTP协议。



通过UNC路径访问内容的一种替代方法是使用WebDAV协议。一些内容管理系统(如MS SharePoint)使用WebDAV来提供对文档和页面的访问。就最终用户体验而言,它看起来和感觉就像使用UNC路径访问网络文件一样;但是,所有文件交互都是通过HTTP执行的。



可能需要对文件访问原理进行适度更改,所以我建议您阅读有关WebDAV协议,配置和权限管理,因为它涉及到你的特定服务器技术。
〜回答kbrimington


I’m trying to open a local file through html anchor link but it is not opening in Firefox.

This is the code

<a href="file:///\\10.0.4.4\001-100 Design Projects\">log</a>

if I try to reach this destination through browser url by putting this

file:///\\10.0.4.4\001-100 Design Projects\

it opens but it does not work with anchor. I’m reminding that it works okay in chrome. I want to know the work around for this problem.

Thanks in advance

解决方案

Have a look at this post for the particular restrictions in Firefox: Workaround for href="file://///..." in Firefox

Here is a summary of answers:

  • 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 in http://www.techlifeweb.com/firefox/2006/07/how-to-open-file-links-in-firefox-15.html - 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 reported that it doesn't work also.
  • Use the locallinks Firefox extension - this apparently just sets the Security.fileuri.strict_origin_policy to true for you, and also appears to have no 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://.

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. ~ Answer by kbrimington

这篇关于如何打开本地文件的href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆