问题
Is the file protocol effectively defunct?
It would be extremely useful to me if an intranet server could generate links such as
<a href="file:///shared/customer_info/customer-name">
<a href="file:///shared/customer_info/customer-name/history.ods">
Since it's an internal intranet app, the server and the users' systems share access to the same filestore, so this is sensible.
Unfortunately, Firefox and Chrome have disabled file://
links. The only thing I can do with them is right-click, copy link location, and then paste it into a file manager location bar or even into the browser's own location bar (in which case they work beautifully!)
Is there a documented way to re-enable them on the browser? Preferably, if there are major security issues, selectively, so that only file://
links coming from a server on the local net are acted upon.
(I'm aware that there's a Firefox plugin "Local filesystem links" that provides some of this functionality, but I'd be hesitant about making my employer dependant on it since Firefox has something of a history of breaking plugins. Also most of the users prefer Chrome. )
回答1:
No the protocol is not defunct, but it is not a web protocol which is primarily what web browsers were designed for. file://
works in IE and Chrome version 55.0.2883.87 but as you said does not work in Firefox. In a Windows environment, the file protocol, while constructed like a web URL is actually just SMB behind the scenes. Its the same as using a UNC path but allows you to use hyper links and display in a browser.
Its primary use case is for local documentation for product installations (usually help files). It allows accessing the documentation via a web browser and usage of hyperlinks within the documentation. It effectively appears to the end user like a web site, while in fact its just local file access.
For intranet or Internet I recommend setting up http links. Though file://
can work to some degree via intranet I do not recommend it. Especially, as you stated, you already have an http server running.
来源:https://stackoverflow.com/questions/41492417/is-the-file-protocol-for-web-browser-links-defunct