我可以在 html 文件中放置什么元标记,以便它自动在 Microsoft Word 中打开该页面?

发布于 2024-08-03 01:31:49 字数 588 浏览 1 评论 0原文

我的问题与此相关:

有没有一种方法可以在机器上没有word的情况下动态生成word文档

我的同事告诉我,你可以在html头部分中放置一些元标记,这些标记将重定向html并让word将该html页面作为word文档打开。我在框架 3.5 aspx 页面中尝试过,但没有成功。

以下是他建议的内容:

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 11 (filtered)">

我将尝试不同的 asp 框架,看看是否有帮助。

再说一次,如果还不清楚的话。浏览器将连接到该 asp 页面,但随后会看到这些标签并将内容重定向到 MS Word。

My question is related to this one:

Is there a way to generate word documents dynamically without having word on the machine

My co-worker told me however that there are some meta tags you can place inside your html head section that will redirect the html and make word open that html page as a word document. I tried it in a framework 3.5 aspx page but it didn't work.

Here are the lines he suggested:

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 11 (filtered)">

I'm going to try different asp frameworks to see if that helps.

Again, if it wasn't clear. The browser would connect to this asp page but then see those tags and redirect the contents to MS word.

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

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

发布评论

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

评论(4

伴梦长久 2024-08-10 01:31:49

我认为你的同事正在考虑 MIME 类型,而不是元标记。如果您将 MIME 类型设置为 application/msword,并且计算机安装了 Word,则可以正常工作。

某些浏览器插件等可能会监视 标记,但我认为在这种情况下这是对 标记的愚蠢滥用。

I think your coworker is thinking of MIME types, not meta tags. If you set your MIME type to application/msword, and the computer has Word installed, that will work.

It's possible that some browser plugin or such could be monitoring for <meta> tags, but I think that's a silly abuse of <meta> tags in this case.

羁拥 2024-08-10 01:31:49

生成器仅描述文档的来源,即它是使用 Word 创建的。我认为这是不可能的,这样你就可以有一个基本上是病毒的 html 页面,例如自动打开脚本主机。您能做的最好的就是将内容采用文字可读格式并使用它:

Response.Clear();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");

这将产生一个文件保存对话框。

Generator just describes where the document came from, i.e. it was created using Word. I don;t think this is possible, that way you could have an html page that is basically a virus open the script host automatically for instance. The Best you can do is have the content in a word readable format and use this:

Response.Clear();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");

This will produce a file save dialog.

我爱人 2024-08-10 01:31:49

更改元标记不会执行任何操作。您必须更改响应标头中的 mime 类型才能让浏览器在 Word 中打开它。

这是微软帮助页面的链接

http://msdn.microsoft.com/ en-us/library/ms525208.aspx

Changing the meta tags won't do anything. You have to change the mime type in the response header to get the browser to open it in word.

Here is a link to microsoft's help page

http://msdn.microsoft.com/en-us/library/ms525208.aspx

听风念你 2024-08-10 01:31:49

您需要:

<meta http-equiv="Content-Type" content="application/msword">

现在就可以在 Firefox 中进行转换。如果用户

a) 接受在默认处理程序应用程序中打开文件

b) 用户指示 Firefox 始终对 .doc 文件类型采取“打开”操作,则会发生转移

You need:

<meta http-equiv="Content-Type" content="application/msword">

Now for the diversion in Firefox. The diversion will happen if the user either

a) accepts to open the file in the default handler application

b) the user has instructed firefox to always take the 'open' action for .doc file types

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