如何使用JavaScript来呈现Word文档(DOC,DOCX)在浏览器 [英] How to render word document(DOC,DOCX) in browser using Javascript

查看:5153
本文介绍了如何使用JavaScript来呈现Word文档(DOC,DOCX)在浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地做​​了code,显示在浏览器中,而不是打开打开/保存对话框中的PDF文件。现在,我被困在浏览器中显示Word文档。我想显示在Firefox,IE7 +,铬等word文档。

I have successfully done code to display pdf file in browser instead of open "Open/Save" dialog. Now I stuck on to display word document in browser. I want to display word document in firefox, IE7+, chrome etc.

任何一个可以帮助。我总是收到打开/保存对话框,而在browser.I显示Word文档要使用JavaScript来实现此功能。

Can any one help. I am always getting "Open/Save" dialog while displaying word doc in browser.I want to implement this functionality using JavaScript.

推荐答案

没有浏览器目前拥有必要的code呈现Word文档,而据我所知,有一些目前存在的无客户端库使他们无论是

No browsers currently have the code necessary to render Word Documents, and as far as I know, there are no client-side libraries that currently exist for rendering them either

不过,如果你只需要显示Word文档,但不需要进行编辑,您可以通过使用谷歌文档文件查看器< IFRAME> 显示远程托管 .DOC / .DOCX

However, if you only need to display the Word Document, but don't need to edit it, you can use Google Documents' Viewer via an <iframe> to display a remotely hosted .doc/.docx.

<iframe src="http://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

改编自解决方案如何使用显示Word文档的fancybox

例如:

的jsfiddle

不过,如果你宁愿有原生支持,在大部分,如果不是所有的浏览器,我建议你重新保存 .DOC / .DOCX 为PDF文件的那些也可以独立使用 PDF.js 通过Mozilla的渲染

However, if you'd rather have native support, in most, if not all browsers, I'd recommend resaving the .doc/.docx as a PDF file Those can also be independently rendered using PDF.js by Mozilla.

编辑:

巨大的感谢 fatbotdesigns 在评论张贴在Microsoft Office 365浏览器。

Huge thanks to fatbotdesigns for posting the Microsoft Office 365 viewer in the comments.

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://remote.url.tld/path/to/document.doc' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>

活生生的实例:

谷歌文档查看器

的Microsoft Office浏览器

这篇关于如何使用JavaScript来呈现Word文档(DOC,DOCX)在浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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