对于 Intranet Web 应用程序(文档管理),我想显示与特定客户关联的文件列表。生成的 HTML 如下所示:
<a href="file:///server/share/dir/somefile.docx">somefile.docx</a>
<a href="file:///server/share/dir/someotherfile.pdf">somefile.pdf</a>
<a href="file:///server/share/dir/yetanotherfile.txt">yetanotherfile.txt</a>
这工作正常。不幸的是,当单击文本文件(或图像文件)时,Internet Explorer(我猜大多数其他浏览器也是如此)坚持在浏览器中显示它,而不是使用关联的应用程序(例如记事本)打开文件。在我们的例子中,这是不希望的行为,因为它不允许用户编辑文件。
是否有一些解决方法可以解决此行为(例如
之类的内容)?我知道这是一个特定于浏览器的事情,并且仅适用于 IE 的解决方案就可以了(毕竟它是一个 Intranet 应用程序)。
For an Intranet web application (document management), I want to show a list of files associated with a certain customer. The resulting HTML is like this:
<a href="file:///server/share/dir/somefile.docx">somefile.docx</a>
<a href="file:///server/share/dir/someotherfile.pdf">somefile.pdf</a>
<a href="file:///server/share/dir/yetanotherfile.txt">yetanotherfile.txt</a>
This works fine. Unfortunetly, when clicking on a text file (or image file), Internet Explorer (and I guess most other browsers as well) insist on showing it in the browser instead of opening the file with the associated application (e.g. Notepad). In our case, this is undesired behavior, since it does not allow the user to edit the file.
Is there some workaround to this behavior (e.g. something like <a href="file:///..." open="external">
)? I'm aware that this is a browser-specific thing, and an IE-only solution would be fine (it's an Intranet application after all).
发布评论
评论(2)
你想让人们乱搞你服务器上的东西吗?这对我来说缺乏安全性......
我建议让用户在本地签出并使用数据库或类似的东西来允许人们签入新草稿。所述草稿在实际写入服务器的文件系统之前应该以某种方式进行验证和验证。
Do you WANT people to just mess around with things lying on your server? That reeks of lack of security to me...
I'd recommend letting the user check it out locally and using a database or similar to allow people to check in new drafts. Said drafts should be verified and validated somehow before they are actually written to the server's filesystem.
我刚刚测试了这个,它似乎可以工作(IE6,不在 FF 或 Chrome 中):
在此处找到它。
I just tested this and it seems to work (IE6, not in FF or Chrome):
Found it here.