How do I render a Word document (.doc, .docx) in the browser using JavaScript?

open word document in browser using jquery
view doc file in browser using javascript
how to display a word document (.doc) file in html page
javascript document viewer
preview doc file in html
how to display docx file in html
viewerjs docx
jquery display word document

I have successfully done code to display a PDF file in the browser instead of the "Open/Save" dialog. Now, I'm stuck trying to display a Word document in the browser. I want to display a Word document in Firefox, IE7+, Chrome etc.

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

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.

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="https://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

Solution adapted from "How to display a word document using fancybox".

Example:

JSFiddle

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.

Edit:

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>

One more important caveat to keep in mind, as pointed out by lightswitch05, is that this will upload your document to a third-party server. If this is unacceptable, then this method of display isn't the proper course of action.

Live Examples:

Google Docs Viewer

Microsoft Office Viewer

How to view Word document in browser using JavaScript, doc/. docx as a PDF data Those can easily also be actually separately rendered using PDF.js by Mozilla. No internet browsers currently have the  Indigenous Documents (through which I possess an enthusiasm) produces a viewer (and editor) particularly for Word documents (both heritage binary.doc as well as contemporary docx layouts). It does this without lossy sale to HTML. There is actually an internet demo where you can attempt your very own document.

The answers by Brandon and fatbotdesigns are both correct, but having implemented the Google docs preview, we found multiple .docx files that couldn't be handled by Google. Switched to the MS Office Online preview and works likes a charm.

My recommendation would be to use the MS Office Preview URL over Google's.

https://view.officeapps.live.com/op/embed.aspx?src=http://remote.url.tld/path/to/document.doc' 

Preview MS Word docx Document in Browser, I want to implement this functionality using JavaScript. Answers: No browsers currently have the code necessary to render Word Documents,  How to render word document(DOC,DOCX) in browser using Javascript Tag: javascript , jquery , asp.net-mvc I have successfully done code to display pdf file in browser instead of open "Open/Save" dialog.

How to view a file like .doc, .PDF, and .xls in a browser using , This article explains how to view a Word document in browser using JavaScript with Essential JS 2 JavaScript Word Processor Element which will render as DocumentEditor -->; <div id="DocumentEditor" style="height:  word docx preview in client web browser How do I render a Word document (.doc, .docx) in the browser using JavaScript How do you preview a Word document in HTML How do I display a Word document as a HTML document HTML5 word docx viewer in web browser javascript read word docx How To Preview word Doc Files In client-side Browser

ViewerJS is helpful to view/embed openoffice format like odt,odp,ods and also pdf.

For embed openoffice/pdf document

<iframe src = "/ViewerJS/#../demo/ohm2013.odp" width='700' height='550' allowfullscreen webkitallowfullscreen></iframe>

/ViewerJS/ is the path of ViewerJS

#../demo/ohm2013 is the path of your file want to embed

How to render word document(DOC,DOCX) in browser using , mammoth.js render word docx on Browser Example demo | word docx preview in client web browser | How do I render a Word document (.doc, .docx) in the  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. 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 .

Native Documents (in which I have an interest) makes a viewer (and editor) specifically for Word documents (both legacy binary .doc and modern docx formats). It does so without lossy conversion to HTML. Here's how to get started https://github.com/NativeDocuments/nd-WordFileEditor/blob/master/README.md

How To Preview Doc And PDF Files In Browser, No browsers currently have the code necessary to render Word Documents, .​docx as a PDF file Those can also be independently rendered using PDF.js by  Client-side JavaScript obtains the Word template document in docx format, either from a server, or by asking the user for a file upload (which it can then read using the FileReader API) The JavaScript uses its local data structures (e.g., data lists it has obtained via Ajax) to expand the template into a document.

How to display word document in browser window?, How to render word document(DOC,DOCX) in browser using Javascript. Question. I have successfully done code to display pdf file in browser instead of open  The approach used in this example is based upon conversion of the Word document into an MHT file.This conversion is accomplished by using the Word file Save As option and selecting the MHT file type prior to saving.The MHT file type is a single web page with all content embedded.

how to display word document in browser in localhost , File preview seems to be a common thing, so many developers might think that that asking Google 'How to preview Word document in browser' would be Looking it up on Google will most likely lead you to use Google docs viewer In JavaScript create an Interval which every few seconds will try to get  when i open the page in chrome and firefox it downloads the file when the link is clicked but, IE does not download it, instead it opens it in the IE browser itself showing weird characters. i want IE to either open the file in word or should prompt, do u want to open or save the file. i am using spring MVC framework and deploying the webapp on

We are able to achieve this for PDF file but for Word (.doc or .docx) How to render word document(DOC,DOCX) in browser using Javascript. Word has several different visual layouts when editing a document. Most users are used to the “Print Layout”, which mimics how the document will look if printed. By default, when Word interprets an HTML document it will show the document in “Web Layout”. Some users might find this disconcerting,

Comments
  • stackoverflow.com/questions/9418850/…
  • @Pankaj You do not have to upload it to Google Drive. You can just change the url paramteter to the full URL to the .doc file, either hosted on your server, or anywhere it can be directly linked to. Google Docs handles the conversion to a format that can be handled by the browser on the fly, and does not require it to be uploaded or stored on Google Docs, instead performing a server-side request to grab the file.
  • @Pankaj Even if you're hosting a local server, Google cannot access localhost. It needs a publicly accessible URL. You could use a basic forwarding service like Finch.
  • You could also use the office live apps viewer: //view.officeapps.live.com/op/embed.aspx?src=your_url_here put this url in an iframe
  • @BonifacePereira If you're setting up an intranet, you'll probably have to do some conversion locally, since GDocs and Live would both have to fetch the document from somewhere. If you're able to, you might be able to set up a server for conversion with OpenOffice or something: stackoverflow.com/questions/5538584/…
  • Just want to point out that both of these methods definitely upload the files to Google's and Microsoft's servers. If you are dealing with sensitive information that should have limited access- do not do this. Use the alternative solution with PDF.js to generate a PDF version of the file to view in the browser and offer a link to download the various excel/doc versions.
  • Is there any restriction to use this ? support.microsoft.com/en-us/help/2769380/…
  • to provide a counter narrative - we chose the google version because the microsoft renderer takes a lot longer to load in both chrome and ff
  • I will note that my library is completely unmaintained. It was able to convert docx files to something that could be rendered in the browser. I don't know if this is true anymore.
  • Shall i able use the link url from aws s3