AllExperts > DHTML 
Search      
DHTML
Volunteer
Answers to thousands of questions
 Home · More DHTML Questions · Answer Library  · Encyclopedia ·
More DHTML Answers
Question Library

Ask a question about DHTML
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Andrew Hoffman
Expertise
I can field just about any question within this topic ranging from JavaScript to CSS, the two ingredients of DHTML. I`m very interested in the W3C and its validation rules for HTML, XHTML, and CSS, and enjoy answering questions of this type as well. I detest sleep and respond at all hours of the day or night.


Experience
Experience in the area
I've been working with DHTML and CSS for 7 years now and build/maintain websites of my own that implement DHTML navigation.

What I'm doing now
My contract with Microsoft has ended and I am working for myself once again. Please contact me for any front-end work at antibland@gmail.com

 
   

You are here:  Experts > Computing/Technology > HTML/XML > DHTML > animated GIF for a PDF download

DHTML - animated GIF for a PDF download


Expert: Andrew Hoffman - 3/9/2009

Question
Hi

My question is that I have a free PDF ebook on my website that is 1.8 MB in size and it takes a few seconds to load in the browser. Right now I have a .jpg download button with a link to my PDF download.  Here is my website link.. http://shenreed.com/index.html  and Book 1 is the large PDF

What I would like to do is two things....

1) To be able to show a animated “loading” GIF on the white browser page as the PDF loads so that people know that it’s loading and for it to stop when the page has loaded.

2) Have the option to have direct download pop up, instead of having to go through clicking on “file” and then “save as” routine.

I’ve tried searching the web for an answer but I’m lost with all the different coding. I am somewhat familiar with html and a bit of CSS code and the odd self contained java script as I did build my website. These features would just make things a little more user friendly. Any help would be appreciated,

Regards
John


Answer
John,

1) Cannot be done.  The white browser page is actually the PDF--there's unfortunately nowhere to put a loading image.  There's no workaround for this.

2) Although this question is out of the scope of DHTML, I can point you to an answer in PHP.

<?php
header('Content-Type: application/save');
header('Content-Disposition: attachment; filename=filename.pdf');
readfile(http://www.site.com/filename.pdf);
?>

You would put this at the very top of your php page.  That means, your index.html page would need to be index.php for the above lines to work. Hopefully, your web host provides PHP support.  If you don't find success using this method, try searching for answers in the PHP section of this site or elsewhere on a PHP forum.

- Andrew  

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.