admin管理员组文章数量:1353303
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="://domain/path/docFile.doc&embedded=true">open a word document in fancybox</a>
My Piece
$path="resume/".$row['resume'];
echo "<br /><a class='word' href='=".$path."&embedded=true'>View Resume</a>";
M i giving the path incorrectly ?
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./gview?url=http://domain./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./gview?url=".$path."&embedded=true'>View Resume</a>";
M i giving the path incorrectly ?
Share Improve this question asked Mar 4, 2016 at 5:36 PooojaaaaPooojaaaa 1791 gold badge4 silver badges16 bronze badges 6-
is it
$path = http://domain./path/docFile.doc
??echo $path
chk the result – devpro Commented Mar 4, 2016 at 5:43 -
is it working fine?
http://docs.google./gview?url=http://domain./path/docFile.doc&embedded=true
if u hit on browser – devpro Commented Mar 4, 2016 at 5:47 - no .. it's only showing no preview available – Pooojaaaa Commented Mar 4, 2016 at 5:54
- hit this url: domain./path/docFile.doc in browser, working? – devpro Commented Mar 4, 2016 at 5:58
- Let us continue this discussion in chat. – devpro Commented Mar 4, 2016 at 6:01
2 Answers
Reset to default 4You 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./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./op/embed.aspx?src=your_url_here
put this url in an iframe
<iframe src='https://view.officeapps.live./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.'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office./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
The $path
has to be a full external path so that google docs can access it. You cant use a relative path like you are for this. The document will have to be internet facing to use this code.
本文标签: javascripthow to display word document in browser in localhostStack Overflow
版权声明:本文标题:javascript - how to display word document in browser in localhost? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743926443a2563047.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论