如何在本地主机的浏览器中显示word文档? [英] how to display word document in browser in localhost?

查看:59
本文介绍了如何在本地主机的浏览器中显示word文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从stackoverflow得到了这段代码,它可以在浏览器中显示word文档..是否可以只在本地主机中显示word文档..尝试这段代码后bcz..它只向我显示没有预览可用"..

$(document).ready(function() {$(".word").fancybox({'width': 600,//或其他'高度':320,'类型':'iframe'});});<a class="word" href="http://docs.google.com/gview?url=http://domain.com/path/docFile.doc&embedded=true">在花式盒子</a>

我的作品

$path="resume/".$row['resume'];echo "<br/><a class='word' href='http://docs.google.com/gview?url=".$path."&embedded=true'>查看简历</a>";

我给出的路径不正确?

解决方案

你不能.浏览器没有任何内置方式来查看 Word 文档,因此除非用户将浏览器配置为使用某些插件打开它(世界上 99% 的人都没有这样做),否则浏览器会提示他们下载文件.

因此,目前没有浏览器具有渲染 Word 文档所需的代码,据我所知,目前也没有用于渲染它们的客户端库.

您可以通过

使用 Google 文档的查看器

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

您可以在 SO 链接上查看解决方案>

如果您想使用下载脚本打开文件,则可以使用

<块引用>

内容类型:application/vnd.ms-word

您可以使用 office live apps viewer,需要互联网连接://view.officeapps.live.com/op/embed.aspx?src=your_url_here

将此网址放入 iframe

<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'>这是一个嵌入的<a target='_blank' href='http://office.com'>Microsoft Office</a>文档,由<a target='_blank' href='http://office.com/webapps'>Office Online</a>提供支持.</iframe>

如果您只想显示内容,则可以将 word 文件转换为 pdf 文件类型.您可以使用 cloud convert 将文件从一个格式到另一个.目前云转换支持多达 128 种不同的文件格式.

还有另一个 SO 链接用于文件格式转换

I got this code from stackoverflow which can display the word document in browser.. Can it be possible to display the word document in localhost only .. bcz after trying this code .. It's only showing me "no preview available" ..

$(document).ready(function() {
$(".word").fancybox({
'width': 600, // or whatever
'height': 320,
'type': 'iframe'
});
}); 

<a class="word" href="http://docs.google.com/gview?url=http://domain.com/path/docFile.doc&embedded=true">open a word document in fancybox</a>

My Piece

$path="resume/".$row['resume']; 
echo "<br /><a class='word' href='http://docs.google.com/gview?url=".$path."&embedded=true'>View Resume</a>";

M i giving the path incorrectly ?

解决方案

You can't. Browsers don't have any built-in way to view Word docs so unless the user has configured their browser to open it with some plugin (which 99% of the world hasn't done), the browser will prompt them to download the file.

So 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.

you can use Google Documents' Viewer via an

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

You can check solution at SO link

IN case if you wants to open file using download script then you can use the

Content-type: application/vnd.ms-word

<?php
header('Content-type: application/vnd.ms-word');
header('Content-Disposition: attachment; filename="document.doc"');
readfile('path-to-file.docx');
?>

You can use the office live apps viewer , internet connection is required: //view.officeapps.live.com/op/embed.aspx?src=your_url_here

put this url in an iframe

<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>

If you only wants to display the content then you can convert word file to pdf file type. You can use cloud convert to convert files from one format to another. Currently cloud convert supports upto 128 different file formats.

There is another SO link for file format conversion

这篇关于如何在本地主机的浏览器中显示word文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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