how to create an anchor to a file in remote server

2019-08-03 05:44发布

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

Browser : Chrome

1条回答
Ridiculous、
2楼-- · 2019-08-03 06:18

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. You need to get the user to install this Chrome extension
  2. It must be over https://

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

Further reading

查看更多
登录 后发表回答