Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    c q
    c q is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent the Save As... dialog when linking to files

    Hi!

    I'm trying to solve this nagging problem for a while now.. but haven't succeeded yet.

    I have an e library database implemented, where teachers can upload their resources (could be ppt, pdf, doc whatever...)

    they can then use each others' resources in their elearning courses by adding a link.

    I noticed that everytime i try to link something in a course, clicking them throws up a "save as" dialog. Whether i link them, add them in a frame, iframe or a separate popup window altogether.

    I want to force the files to open in the browser window itself. How can I make it happen?

    thanks in advance.
    c q.
    It's a new world. It's a new day.
    www.nehasaxena.com : : www.kohimaorphanage.org

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,378
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    The dialog box is a function of the PC itself. With Windows, you can
    tell the browser to "open as" any particular filetype without a dialog box.
    You don't really have control over that with your website.

    On my PC with Firefox, when I click on a PDF link, it opens it right up with
    Acrobat Reader in it's own window, same with .doc type .. only because I
    set-up the "open with" filetypes that define which program opens which links.

    There are ways to output .doc and .pdf (and other types) directly into the
    browser using some server-side scripts. Things like PDF to HTML on-the-fly.
    This involves having your own server with the PHP or Perl modules installed.

    This type of thing is very similar to PHP GD library which can alter .jpeg
    images (resize, crop, watermark, etc) on-the-fly before serving them to
    the visitor's browser ... instead, it does the same thing with various text
    types.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,461
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Whether a SaveAs displays depends on two things.

    1. Is the file being delivered to the browser with a disposition of inline or attachment. If attachment then the SaveAs will always display.
    2. For disposition inline, it then depends on whether the browser knows how to display it. If it can display the file it will, if it can't it will offer SaveAs.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    c q
    c q is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I am running it in my own WAMP server.

    How do i configure the headers so that the browser loads the document inline no matter what the client browser setting? Also, if the user does not have the right application (say acrobat for pdfs...) I would like some script to prevent the save as dialog box.

    any pointers, friends?
    It's a new world. It's a new day.
    www.nehasaxena.com : : www.kohimaorphanage.org

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,461
    Thanks
    0
    Thanked 632 Times in 622 Posts
    If the browser doesn't have a plugin to handle a particular file type then it can't display that file in the browser regardless. You can force a file to be offered for download by setting the Content-disposition to attachment but you can't force it to load in a browser if the browser or browser owner doesn't want it to.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    You may be interested to know that PDF and DOC files are not suitable for online reading due to being bad for usability and accessibility.

    My advice would be to always force a download for this type of content, and to provide it in HTML for online use as well.

    See http://www.useit.com/alertbox/20030714.html for more info <-- this equally applies to other non standard document formats as well.

  • #7
    c q
    c q is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't like pdfs either, but unfortunately, I have to use this file format because my bosses seem to love it. I am already facing problems with slideshows not behaving the same in different computers due to different acrobat reader versions. But i have to work around it but i cannot abandon pdf.

    What they essentially want is that the documents should only be readable on screen. No printing options, no save as options. Ofcourse, i could argue that one can still take screenshots and print, or recover the file from their temp folders... but we're talking about fairly non techie bank operations staff here. It would be enough if they are not given any save as options upfront in the website. They would not try too hard to recover them.

    One answer is a rights management server... but its an expensive affair.

    The other solution is to password protect the file. My elearning portal can pass variables into the files, so only legitimate open requests which are routed through the elearning server can open the file. Even if they save the file and go home, they'd need a password to open it. Now again, they would not be so desperate as to get a password crack.

    But this is a slightly wrong forum to ask this in... still.... does anyone know what variable name is this password field known as in a pdf? :-/
    It's a new world. It's a new day.
    www.nehasaxena.com : : www.kohimaorphanage.org

  • #8
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,378
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    I would say that you would be looking into something other than an
    internet browser. Like a dedicated program in C++ or VBasic that
    is similar to a kiosk. This could then turn-off any screen saving, printing,
    keyboard functions, etc ... making the mouse the only input device.

    Some sort of software like that could access the files from the internet,
    yet have total control over the viewer, unlike a browser.

    You should look into some Kiosk type software.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •