在浏览器外部打开" />

确保 在浏览器外部打开

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千笙结 2024-09-07 02:15:12

你想让人们乱搞你服务器上的东西吗?这对我来说缺乏安全性......

我建议让用户在本地签出并使用数据库或类似的东西来允许人们签入新草稿。所述草稿在实际写入服务器的文件系统之前应该以某种方式进行验证和验证。

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.

極樂鬼 2024-09-07 02:15:12

我刚刚测试了这个,它似乎可以工作(IE6,不在 FF 或 Chrome 中):

<HTML>
<script language="JavaScript">
  function startWord(strFile)
  {
    var myApp = new ActiveXObject("Word.Application");
    if (myApp != null)
    {
      myApp.Visible = true;
      myApp.Documents.Open(strFile);
    }
  }
</script>
<a href="javascript:startWord('file:///server/share/dir/test.doc')">test.doc</a>.

此处找到它。

I just tested this and it seems to work (IE6, not in FF or Chrome):

<HTML>
<script language="JavaScript">
  function startWord(strFile)
  {
    var myApp = new ActiveXObject("Word.Application");
    if (myApp != null)
    {
      myApp.Visible = true;
      myApp.Documents.Open(strFile);
    }
  }
</script>
<a href="javascript:startWord('file:///server/share/dir/test.doc')">test.doc</a>.

Found it here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文