I am currently using the meta http-equiv=’Refresh’ to automatic start PDF downloads. however this has different effect on each of the browsers.
The main problem is with IE (6 & 7) once the user is redirected to the PDF if the user click the back button they are sent back to the page that initiated the download and then promptly redirect to the PDF again.
Firefox on windows has a better affect but still not perfect the user gets to the download page and is redirected to the PDF. However if they use the back button the completely miss the download page.
Currently Firefox on Linux has the exact effect i want. Being that the download page redirects you to the PDF and the back button from the PDF sends you back to the download page and there you stay.
I have tried using the javascript setTimeout() function to delay a pop-up of the PDF however the delay does not seem to work in any browser and the pop-up does not seem to work in IE7.
Has anyone implemented an elegant solution to the problem that i could use?
Thanks in advance for you help
Referrer
You could check the referrer:
It’s a little bit more complex because you have to compare to the absolute URL of the referrer, but this shouldn’t be a problem.
Cookies
You could set a cookie the first time you enter the download page. If the cookie is set (for every file another entry in the cookie) then you shouldn’t redirect.
A disadvantage is that if someone reloads the page (because he wants to see the file a second time) he can’t access the file anymore. There are some possibilities around it:
Setting/Getting a cookie:
Javascript can redirect like this: