简体   繁体   English

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

[英]What meta tag can I place inside my html file so that it opens that page in microsoft word automatically?

My question is related to this one: 我的问题与此有关:

Is there a way to generate word documents dynamically without having word on the machine 有没有一种方法可以动态生成Word文档而无需在计算机上放置单词

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. 但是我的同事告诉我,您可以在html头部分中放置一些元标记,这些元标记将重定向html并使单词以word文档形式打开该html页面。 I tried it in a framework 3.5 aspx page but it didn't work. 我在框架3.5 aspx页面中尝试了它,但是没有用。

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. 我将尝试使用不同的ASP框架,以查看是否有帮助。

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. 浏览器将连接到该asp页面,但随后会看到这些标签并将内容重定向到MS word。

I think your coworker is thinking of MIME types, not meta tags. 我认为您的同事正在考虑MIME类型,而不是元标记。 If you set your MIME type to application/msword , and the computer has Word installed, that will work. 如果将MIME类型设置为application/msword ,并且计算机安装了Word,则可以使用。

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. 可能某些浏览器插件或类似工具可能正在监视<meta>标签,但是在这种情况下,我认为这是对<meta>标签的愚蠢滥用。

Generator just describes where the document came from, ie it was created using Word. 生成器仅描述文档的来源,即它是使用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. 我不认为这是可能的,这样,您可能会有一个HTML页面,该页面基本上是病毒,例如,自动打开脚本宿主。 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. 这将产生一个文件保存对话框。

Changing the meta tags won't do anything. 更改meta标签不会做任何事情。 You have to change the mime type in the response header to get the browser to open it in word. 您必须更改响应标题中的mime类型,以使浏览器以单词形式打开它。

Here is a link to microsoft's help page 这是微软帮助页面的链接

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

You need: 你需要:

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

Now for the diversion in Firefox. 现在在Firefox中进行转移。 The diversion will happen if the user either 如果用户

a) accepts to open the file in the default handler application a)接受在默认处理程序应用程序中打开文件

b) the user has instructed firefox to always take the 'open' action for .doc file types b)用户已指示firefox对.doc文件类型始终执行“打开”操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM