javascript 在 div 中显示 .doc
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11810336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display .doc inside a div
提问by chris Frisina
It is possible to display a pdf inside a div using this:
可以使用以下方法在 div 内显示 pdf:
<div>
<object data="test.pdf" type="application/pdf" width="300" height="200">
PDF : <a href="test.pdf">test.pdf</a>
</object>
</div>
Is it possible to do something similar for a .doc or .docx? (without server side)
是否可以为 .doc 或 .docx 做类似的事情?(不含服务器端)
- I am assuming the browser or the computer has a way of reading the data.
- 我假设浏览器或计算机有读取数据的方法。
采纳答案by Jasper
Might I suggest Google Doc Viewer, it'll allow you up show several types of files inline where they would normally prompted for download:
我可能会建议使用 Google Doc Viewer,它可以让您在通常会提示下载的位置内联显示几种类型的文件:
https://docs.google.com/viewer/
https://docs.google.com/viewer/
You can also use this inline in your own website with the use of an iframe.
您还可以使用 iframe 在您自己的网站中使用此内联。
Here is a list of supported file-types:
以下是支持的文件类型列表:
- Microsoft Word (.DOC and .DOCX)
- Microsoft Excel (.XLS and .XLSX)
- Microsoft PowerPoint (.PPT and .PPTX)
- Adobe Portable Document Format (.PDF)
- Apple Pages (.PAGES)
- Adobe Illustrator (.AI)
- Adobe Photoshop (.PSD)
- Tagged Image File Format (.TIFF)
- Autodesk AutoCad (.DXF)
- Scalable Vector Graphics (.SVG)
- PostScript (.EPS, .PS)
- TrueType (.TTF)
- XML Paper Specification (.XPS)
- Archive file types (.ZIP and .RAR)
- Microsoft Word(.DOC 和 .DOCX)
- Microsoft Excel(.XLS 和 .XLSX)
- Microsoft PowerPoint(.PPT 和 .PPTX)
- Adobe 便携式文档格式 (.PDF)
- 苹果页面 (.PAGES)
- Adobe Illustrator (.AI)
- Adobe Photoshop (.PSD)
- 标记图像文件格式 (.TIFF)
- Autodesk AutoCad (.DXF)
- 可缩放矢量图形 (.SVG)
- PostScript (.EPS, .PS)
- TrueType (.TTF)
- XML 纸张规范 (.XPS)
- 存档文件类型(.ZIP 和 .RAR)
I messed around with this for mobile output of PDFs but the mobile version had an error that made it impossible to use. Not sure where the development on this product has landed but the desktop version always worked very well.
我把这个用于 PDF 的移动输出,但移动版本有一个错误,无法使用。不确定该产品的开发进展到哪里,但桌面版本总是运行良好。
回答by USTropics
You can do this through an iframe inside the div by linking the source to the path of the file on your server.
您可以通过将源链接到服务器上文件的路径,通过 div 内的 iframe 执行此操作。
<div>
<iframe src="mydoc.docx">myDocument</iframe>
</div>
<div>
<iframe src="mydoc.xslx">myDocument</iframe>
</div>
<div>
<iframe src="mydoc.pdf">myDocument</iframe>
</div>