Cross-browser link to file on local system

2019-01-09 14:42发布

I would like to make a link from a web page to a file on a local filesystem and make it work in all browsers (or at least in Internet Explorer, Firefox and Chrome).

For example, the following works in Internet Explorer:

<a href="\\myserver\doc\info.pdf">Info here</a>

but not in Firefox and Chrome.

Is there a way to make a link that works in all browsers?

Or a way to use javascript to detect which browser it is and then display the appropriate link based on the filename?

2条回答
Summer. ? 凉城
2楼-- · 2019-01-09 15:30

Links to local files on pages that were retrieved via HTTP(S) are deliberately disabled in Mozilla/Firefox, because they can be a security risk, and have been used in attacks in the past.

You can override this behaviour, however. For details, see this article in MozillaZine.

查看更多
Explosion°爆炸
3楼-- · 2019-01-09 15:31

try prefixing your url with file:///

查看更多
登录 后发表回答