webDAV / PHP - 从 HTML 锚点打开 MS Word 文档?

发布于 2024-07-26 11:39:16 字数 602 浏览 5 评论 0原文

有人可以解释这种奇怪(或正常)的行为吗: 我有一个 WebDAV 目录。 在这个文件夹中,我有一个word文档,名为document.doc。

当我打开 Word,然后选择“打开文件”并填写整个 URL http://server/webdav/document.doc 时,Word 将正常打开该文档。 我所做的更改将在单击“保存”时保存。

现在,当我制作一个带有此文档锚点的 HTML 页面时,如下所示:

<a href="http://server/webdav/document.doc">Edit document</a>

它将很好地打开文档,但以只读模式打开!

调查表明,当您使用Word打开该文件时,它也将充当WebDav客户端。 因此它将发送适当的标头来锁定文件等。从锚点调用它,让您的浏览器执行 GET。 然后它会将文档(下载的??)传递到Word。 Word 对文件执行一些 HTTP 调用,但不执行 LOCK 等操作。

有谁知道我该如何解决这个问题? 我可以编写一些 PHP 代码来执行 HTTP 调用等,但是如何在 Word 中获取它呢?

Can someone explain this strange (or normal) behaviour:
I've got a WebDAV directory. In this folder, I have a word document, called document.doc.

When I open Word, and then choose "Open File" and fill in the whole URL, http://server/webdav/document.doc, Word will open the document just fine. Changes I make are being saved on save click.

Now, when I make a HTML page with an anchor to this document like this:

<a href="http://server/webdav/document.doc">Edit document</a>

It will open the document just fine, but opens in Read-Only mode!

Investigation suggests that when you use Word to open the file, it will also function as WebDav client. So it will send the appropriate headers to lock the file etc. Calling it from an anchor, lets your browser do the GET. Then it will pass the document (downloaded??) to Word. Word does some HTTP calls on the file, but no LOCK and so.

Does anyone have any idea how I can solve this? I could write some PHP code to do the HTTP calls and so, but how do I get it in Word then?

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

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

发布评论

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

评论(3

梦幻的心爱 2024-08-02 11:39:16

我没想到这是可能的。 当您通过网络浏览器打开它时,您首先会下载一个副本,然后将其存储在临时文件夹中,然后交给Word。 您正在寻找的是用word打开文档。 因此,您需要做的是让链接打开单词并向其传递一个参数。
一个非常令人讨厌的 hack 是让 php 生成可通过 word 读取的文件,使其打开所需的 webdav 文档。 您可以使用宏来完成此操作,但是a)您需要降低word中的宏安全设置,b)您永远无法依赖其他人完成此操作(因此,这只是您的一个解决方案)。

I wouldn't expect this to be possible. When you open it through your web-browser, you're first downloading a copy that's then stored in a temp folder and then handed to word. What you're looking for is having word open the document. Hence, what you would need to do is have the link open up word and pass it a parameter.
A very nasty hack would be to have php generate files readable by word that make it open the desired webdav-document. You could do this with macros, but a) you'd need to lower your macro security settings in word and b) you'd never be able to rely on others having done this (hence, it's just a solution for you).

寄居者 2024-08-02 11:39:16

请参阅这个问题。 基本上,您使用一些 Javascript 来调用属于 Microsoft Sharepoint 一部分的 ActiveX 对象。

See this question. Basically you use a bit of Javascript that calls an ActiveX object that is part of Microsoft Sharepoint.

回梦 2024-08-02 11:39:16

IIRC、Confluence (Atlassian) 有一个适用于 Firefox 的 WebDav 插件,可以实现此目的(通过单击浏览器中的链接以 WebDav 模式在 Word 中打开文档)。 但不确定它是如何完成的。

IIRC, Confluence (Atlassian) has a WebDav add-in for Firefox that accomplishes this (opening a doc in Word in WebDav mode by clicking on a link in the browser). Not sure how it's done, however.

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