jemz — 2013-02-07T06:42:48-05:00 — #1
Hi, I am making a simple upload that will upload a word document...I am just working from my localhost.,..my question is,Is it possible to view the word document in browser,just like in the google...I want to make a button "view document".and then if the user will click it,it will open the word document.Is this possible?
Thank you in advance.
2ndmouse — 2013-02-07T08:19:25-05:00 — #2
I don't usually recommend iframes and this isn't really a PHP question, but here's a possible DHTML solution:
Place an Iframe inside the page, the place a tartget link to the Iframe, like the below example.
<title>Open Word in Iframe</title>
<TABLE BORDER="1" CELLSPACING="1" CELLPADDING="1" WIDTH="100%">
<TD WIDTH="25%" ALIGN="left" VALIGN="TOP">
<a href="doc1.doc" target="awindow">Doc 1</A><br>
<a href="doc2.doc" target="awindow">Doc 2</A><br>
<a href="doc3.doc" target="awindow">Doc 3</A>
<TD WIDTH="75%" ALIGN="CENTER" VALIGN="TOP">
<iframe name="awindow" frameborder=2 width=580 height=440 src="title.html"></iframe>
Replace the doc names with the word document names.
Replace title.html with the file you want to originally show up in the iframe when the page loads.
felgall — 2013-02-07T13:36:55-05:00 — #3
Why have you provided an HTML 3.2 solution. That version of HTML was replaced by HTML 4 back in 1997 - about 15 years ago.
dresden_phoenix — 2013-02-07T18:05:15-05:00 — #4
The issue currently is actually browser preferences. Even with the solution suggested above, FF, for example, will treat those links as files as ask you to DL ( or open them in WORD). Browsers will only display txt and html files everything else is sent to a helper app.
stomme_poes — 2013-02-08T06:09:11-05:00 — #5
Well, browsers differ on what they'll show as far as filetype. I was completely surprised when doing some user testing on a site where we had links to PDFs open "forward" (no target-blank). Since we did the testing on the browsers and OSes the users were using, they kept accidentally closing their browsers... because the PDF was opened in their browser, and they had expected a new window because that's the behaviour they always see/get at all other sites they visit. This was why I ended up changing PDF links to new tabs/windows.
The reasons I and the other devs had not noticed this was because our browsers and OSes downloaded PDFs like files, leaving the browser pages unchanged.
If someone knows how that all works, please post! I'd be interested in knowing (also partially because all teh Google stuff seems horribly inaccessible to screen readers unless you're using ChromeVox (gee, wonder why...)).