在 html 页面上链接 UNC/网络驱动器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1369147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:47:38  来源:igfitidea点击:

Linking a UNC / Network drive on an html page

htmlhyperlinkunc

提问by Doug

Just a basic html link question.

只是一个基本的html链接问题。

I have an intranet setup, and I need to link to some network drives. They are located on drives such as \server_drive\blahblah\doc.docx

我有一个内部网设置,我需要链接到一些网络驱动器。它们位于诸如 \server_drive\blahblah\doc.docx 之类的驱动器上

Using file:// does not work on either IE8 or Firefox. How can I link to these files?

使用 file:// 不适用于 IE8 或 Firefox。如何链接到这些文件?

回答by Michael Petrotta

To link to a UNC path from an HTML document, use file:///// (yes, that's five slashes).

要从 HTML 文档链接到 UNC 路径,请使用 file://///(是的,这是五个斜杠)。

file://///server/path/to/file.txt

file:////服务器/路径/to/file.txt

Note that this is most useful in IE and Outlook/Word. It won't work in Chrome or Firefox, intentionally - the link will fail silently. Some words from the Mozilla team:

请注意,这在 IE 和 Outlook/Word 中最有用。它不会在 Chrome 或 Firefox 中故意工作 - 链接将无提示地失败。Mozilla 团队的一些话:

For security purposes, Mozilla applications block links to local files (and directories) from remote files.

出于安全目的,Mozilla 应用程序会阻止从远程文件到本地文件(和目录)的链接。

And less directly, from Google:

不那么直接,来自谷歌

Firefox and Chrome doesn't open "file://" links from pages that originated from outside the local machine. This is a design decision made by those browsers to improve security.

Firefox 和 Chrome 不会打开来自本地机器外部的页面的“file://”链接。这是这些浏览器为提高安全性而做出的设计决策。

The Mozilla article includes a set of client settings you can use to override this behavior in Firefox, and there are extensions for bothbrowsersto override this restriction.

Mozilla 文章包含一组客户端设置,您可以使用它来覆盖 Firefox 中的此行为,并且两种浏览器都有用于覆盖此限制的扩展。

回答by bryanbcook

Setup IIS on the network server and change the path to http://server/path/to/file.txt

在网络服务器上设置IIS并将路径更改为http://server/path/to/file.txt

EDIT: Make sure you enable directory browsing in IIS

编辑:确保在 IIS 中启用目录浏览

回答by leus

Alternative (Insert tooltip to user):

替代方法(向用户插入工具提示):

  <style> a.tooltips {position: relative; display: inline;} a.tooltips span { position: absolute;  width:240px;  color: #FFFFFF;  background: #000000;  height: 30px;  line-height: 30px;  text-align: center;  visibility: hidden;  border-radius: 6px; } a.tooltips span:after {  content: '';  position: absolute;  top: 100%;  left: 50%;  margin-left: -8px;  width: 0; height: 0;  border-top: 8px solid #000000;  border-right: 8px solid transparent;  border-left: 8px solid transparent; } a:hover.tooltips span {  visibility: visible;  opacity: 0.8;  bottom: 30px;  left: 50%;  margin-left: -76px;  z-index: 999; } </style>
  <a class="tooltips" href="#">\server\share\docs<span>Copy link and open in Explorer</span></a>