473,394 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Openning .doc's and .ppt's in browser

4
Hello,

I'm stuck once again.

So my web app has a button that launches the next URL in our database. This URL could be a website, .doc, .jpg, .ppt, .pdf, anything really.

My code goes something like this:

Expand|Select|Wrap|Line Numbers
  1. Response.Write("<script language=javascript> {window.open('" & VarUrl & "');}</script>")
This works just fine for webpages and images (and I think even pdf's). It does not work for anything that needs to be downloaded (such as .doc and .ppt).

Surely there's a way to do what I need?

I've found some things that talk about declaring the content type, like:
Response.ContentType = "application/pdf"

But since I don't know what type the current URL is, I would have to do some extension grabbing and a huge switch case to cover every possible extension.

Does this make sense?
Apr 28 '10 #1

✓ answered by Frinavale

I'm not sure what you mean by a "download" warning.

If you want to avoid opening/closing a window simply for downloading purposes you can use a hidden iframe on the page. When the user clicks the link or button to download the file you would execute some JavaScript that would change the iframe's src property to the URL where the browser can download the file from.

I use this trick a lot.

-Frinny

6 3661
Frinavale
9,735 Expert Mod 8TB
Adobe (the creators of the .pdf) has been kind enough to provide a plugin for web browsers that allows the web browser to display the PDF file.

Microsoft (the creators of the .doc and the .ppt) has not provided a plugin that allows web browsers to display these files. Therefore these files must be opened with their associated application (in this case Word or PowerPoint....OpenOffice can also open these files and I'm sure there are some other applications that will as well but my point here is that there is no plugin for the browser to be able to open the file).

Since the browser doesn't know how to open the file it lets the user download it and open it using the appropriate application.

You can try and trick the browser by changing the header type to .pdf...but that's not really going to help you because the Adobe plugin will not know how to open the file.

-Frinny
Apr 29 '10 #2
Xiez
4
@Frinavale
Thank you for your reply.

I think I explained it incorrectly.

It's fine if the user downloads the .doc and views it in Word. The problem was that they were not even given the option to save the file. the window would pop up, then go away.

I am getting closer. I did a window.open, then changed the URL of the new window with a location.replace.

That gets me further, and I get a warning message and an option to download a file. The only problem is that my VPN masks the URL, so when I accept the download, it loads the masked URL and does not download the file.

So... it seems like the best bet would be to avoid that download warning. I'm going to start looking around for that, but in the meantime, if anyone has any other idea, I'm definitely open to them!

Thanks.
Apr 29 '10 #3
Frinavale
9,735 Expert Mod 8TB
I'm not sure what you mean by a "download" warning.

If you want to avoid opening/closing a window simply for downloading purposes you can use a hidden iframe on the page. When the user clicks the link or button to download the file you would execute some JavaScript that would change the iframe's src property to the URL where the browser can download the file from.

I use this trick a lot.

-Frinny
Apr 29 '10 #4
Xiez
4
I don't know what I mean either lol.

If I open up a browser and go to:
http://www.acq.osd.mil/osbp/sbir/sol...0A/army10A.doc

for example, I don't get it. I just get the download prompt and choose save or open. That's what I want to see.

When I do it through my web app (which is through a VPN), a security banner pops up saying "To help protect your security, Internet Explorer blocked this site from downloading files to your computer. Click here for options"

When I click for options, there is an option to "download file". Since my VPN masks the URL, once I click download, it loads the masked URL.

I think the iframe idea would be a great idea if I didn't have regular webpages in the mix that I had to open a browser for. Only other idea is to somehow check if it's a file or a webpage, and send files to an iframe or something along those lines
Apr 29 '10 #5
Frinavale
9,735 Expert Mod 8TB
I don't know why you're seeing that message...but then again I haven't tried what you're doing through a VPN.

You should have control over your own links/buttons....?
You don't have to have all links go through the iframe..just the ones you know are for files.
Apr 29 '10 #6
Xiez
4
Well the problem is that the users are going through the list of URLS in the database. The next URL could be .htm, .html, .aspx, .doc, .jpg, anything. So to go through and grab the extension off the end of the URL and handle every possible extension seems very impractical.

A couple searches showed that it's an IE thing that can be disabled. Unfortunately neither me nor the users have permissions to change the settings lol. So I don't know... It would be nice if they could just use another browser or something, but our VPN only allows IE. We may just have to unmask the URL for the web app. I can't think of anything else.

Anyways, thanks for the help. If you think of anything, please let me know :)
Apr 29 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Mel | last post by:
when downloading files from my site, when file types are known (i.e *.doc) browsers open the file for viewing. is there a way to disable that and just present the save as dialog (same as for...
2
by: ajay | last post by:
Sorry for asking a simple and easily find-able Q. How to open a document link with it's application? Say i have link for .ppt file and i want to open it with MS Power point. By default it opens...
1
by: Gaurav | last post by:
Hi, We are developing a .NET app which has forms authentication. When the user types in the direct URL of an aspx page on the browser, he will be thrown to the login page. But if the URL points...
3
by: b_naick | last post by:
Is there a way to embed a powerpoint slideshow in a webpage? I have an application which requires a slideshow in one of the frames of the application. One option would be to get the users to...
3
by: rahul samant via .NET 247 | last post by:
(Type your message here) I am looking for a code in vb.net to search in pdf , ppt and doc files.please help. -------------------------------- From: rahul samant ----------------------- Posted...
0
by: gggdrdo | last post by:
hi i want read different file types like mp3, .wav, .ppt, .doc, etc. in c/c++. after reading i am doing some processing. aftear doing some processing i need to write back to corresponding original...
3
by: ambrish | last post by:
How can I read any text(PDF/Doc/PPT/rtf/etc.) file using PHP. Ambrish
1
by: celoftis | last post by:
BACKGROUND: I have some PPT slides that have been converted to HTM (ensuring that the show slide animations while browsing checkbox is checked). The original HTM slides have custom animations to...
2
by: thvferrari | last post by:
Hey guys, Does anyone of you know how to count the number of pages that a doc, xls and ppt would print? My objective is to count this number of pages and charge the user per number of pages...
1
by: Muddasir | last post by:
hi every body. i am developing an application through which teacher shuld be able to upload .ppt , .doc and .pdf files. and students shall be ablle to download these files through the given links....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.