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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xiez
    New Member
    • Apr 2010
    • 4

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

    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:

    Code:
    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.Conten tType = "applicatio n/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?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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....O penOffice 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

    Comment

    • Xiez
      New Member
      • Apr 2010
      • 4

      #3
      Originally posted by Frinavale
      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....O penOffice can also open these files too 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
      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.replac e.

      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.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

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

        Comment

        • Xiez
          New Member
          • Apr 2010
          • 4

          #5
          I don't know what I mean either lol.

          If I open up a browser and go to:


          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

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            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.

            Comment

            • Xiez
              New Member
              • Apr 2010
              • 4

              #7
              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 :)

              Comment

              Working...