确保< a href ="本地文件">在浏览器外部打开 [英] Make sure <a href="local file"> is opened outside of browser

查看:142
本文介绍了确保< a href ="本地文件">在浏览器外部打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Intranet Web应用程序(文档管理),我想显示与某个客户相关的文件列表。生成的HTML如下所示:

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>

这很好。不幸的是,当点击文本文件(或图像文件)时,Internet Explorer(以及其他大多数其他浏览器)坚持要在浏览器中显示它,而不是使用相关应用程序(例如记事本)打开文件。在我们的例子中,这是不受欢迎的行为,因为它不允许用户编辑文件。

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.

是否有一些解决此行为的方法(例如< a href =file:/// ...open =external> )?我知道这是一个浏览器特定的事情,并且只有IE浏览器的解决方案将会很好(毕竟这是一个Intranet应用程序)。

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).

推荐答案

你是否希望人们只是在服务器上撒谎?这对我来说缺乏安全感。

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.

这篇关于确保&lt; a href =&quot;本地文件&quot;&gt;在浏览器外部打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆