how to create an anchor to a file in remote server in html

孤者浪人 提交于 2019-12-24 14:24:10

问题


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:


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



来源:https://stackoverflow.com/questions/19453415/how-to-create-an-anchor-to-a-file-in-remote-server-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!