我有一个为自己创建的小型 php 系统。该系统包含一些.doc 和.docx 文件文档。我希望能够直接从浏览器打开它们,而不是下载它们。
我创建了一个链接:
<a href="file:///c:/mysite/myfile.docx">myfile</a>
但是 FireFox 不会打开链接。同时 href="http://localhost/myfile.docx"
工作正常 - 它让我下载文件。
我该怎么做? 也许更改 firfox 选项/安全设置中的某些内容? 如果您愿意,是否有机会在 IE8 中做到这一点?
谢谢。
最佳答案
虽然我仍然认为这是一道编程题,但在这里得到了解答: https://superuser.com/questions/103026/open-a-direct-file-on-the-hard-drive-from-firefox-file
Firefox 和 IE8 都支持 File URI scheme .
Here are some examples valid for Windows systems, referring to the same file c:\WINDOWS\clock.avi
file://localhost/c|/WINDOWS/clock.avi
file:///c|/WINDOWS/clock.avi
file://localhost/c:/WINDOWS/clock.avi
file:///c:/WINDOWS/clock.avi虽然最后一个是最明显的 人类可读的,第一个是 最完整和正确的。
显然(来自相同的 url):
Mozilla browsers refuse to follow file URLs on a page that it has fetched with the HTTP protocol.
但是:
Mozilla browsers can be configured to override this security restriction as detailed in Mozillazine's "Links to Local Pages Don't Work".
关于html - 从 firefox 打开硬盘驱动器上的直接文件(文件 :///),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2148584/