如何在html中的远程服务器中创建文件的锚点

问题描述:

我正在公司内部网中创建本地Web门户.在页面中,我需要提供指向远程服务器中某些excel工作表的链接.

I am creating a local web portal in my company intranet. In a page I need to give links to some excel sheets in a remote server.

urlFile='file://ed1/cf/a/b/c.xls';
var regRsltLink = $("<a />", {
       href : urlFile,
       text : "heading",
}).appendTo("#legPassRate");

锚链接看起来很好.当我单击链接时,没有任何反应.但是,当我复制链接地址并粘贴到新选项卡中并启动它时,会出现一个文件下载对话框,并且文件下载正常.当我单击锚链接时,是否可以启动文件下载对话框.复制链接地址时,得到以下链接路径.

The anchor link appears fine. When I click the link, nothing happens. But when I copy the link address and paste in a new tab and launch it, a file download dialog appears and file downloads fine. Is it possible to initiate a file download dialog when i click the anchor link. I get the following link path when i copy the link address.

file://ed1/cf/a/b/c.xls

浏览器:Chrome

Browser : Chrome

对于ChromeSafariOpera,由于其安全模型,不可能.但是,对于Chrome有些解决方案,虽然可以,但有两个要求:

For Chrome, Safari and Opera this isn't possible due to their security model. However, there is somewhat of a solution for Chrome in that it's possible but it has two requirements:

  1. 您需要让用户安装此Chrome扩展程序
  2. 必须在https://
  1. You need to get the user to install this Chrome extension
  2. It must be over https://

由于Firefox通常需要LocalLink,因此您可能会遇到相同的问题.

You will probably encounter the same problem for Firefox since it usually requires LocalLink.

进一步阅读