Skip navigation
Currently Being Moderated

PDFs

Jun 23, 2012 4:01 AM

When you make a link to a PDF file that is in your own site root, how can you make a link back with out having to use the back arrow on the browser, can any one help please thanks Jeff

 
Replies
  • Currently Being Moderated
    Jun 23, 2012 6:10 AM   in reply to Jeffrey54 Lane

    The most elegant way is to force a download similar to what would happen if you had a linked Word document.

     

    If you have access to PHP, have a look here or if you want to use JS have a look at this answer http://stackoverflow.com/questions/365777/starting-file-download-with- javascript

     

    Gramps

     

    Sorry, here is the PHP link http://webdesign.about.com/od/php/ht/force_download.htm

     

    Message was edited by: Altruistic Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 7:15 AM   in reply to Jeffrey54 Lane

    Sorry, I modified the original post to include the link. But if you are happy with a PHP solution, I will certainly help you.

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 8:13 AM   in reply to Jeffrey54 Lane

    Congratulations, I enjoy the grandkids more than I did my own kids, mainly because have more time on my hands.

     

    I know that PDF files do open in a browser window, but for years now, I have claimed that a PDF file should open in its native document window because its behaviour is different to an HTML document. There is nothing more confusing to us oldies then to click on a PDF link only to find that we have lost our original page. The PDF page looks different and we do not realise that we have to click the back button to return to the original page. If we click a Word link, we are taken to Word to show the document. The same applies to an Excel link, then why not a PDF link.

     

    If you go to http://pleysier.com.au/jeffrey/ you will see what I mean. Try in different browsers to see how each reacts differently.

     

    The document markup can be seen when you view the source code. The script for pdf_dl.php is as follows

     

    <?php
    if (isset($_GET['file'])) {
        $pdffile = $_GET['file'];
        header('Content-disposition: attachment; $pdffile.pdf');
        header('Content-type: application/pdf');
        readfile(''.$pdffile.'.pdf');
    }
    ?>

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 8:24 AM   in reply to Ben Pleysier

    Sorry I made a booboo with the PHP file. It should read

     

    <?php
    if (isset($_GET['file'])) {
        $pdffile = $_GET['file'];
        header('Content-disposition: attachment; filename='.$pdffile.'.pdf');
        header('Content-type: application/pdf');
        readfile(''.$pdffile.'.pdf');
    }
    ?>

     

    Gramps

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2012 9:03 AM   in reply to Jeffrey54 Lane

    I don't know which browser you used, but in FF it shows as

    _Capture.jpg

    In IE it shows as

    _Capture.jpg

    in Chrome

    _Capture.jpg

    in Safari it is also very similar.

     

    Gramps

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points