View Full Version : Want Download To Open
marain
02-01-2018, 11:25 PM
Hi Folks, and Happy New Year or (if you prefer), happy Groundhog Day.
Here's my question: When I link to a .pdf file, the .pdf file downloads. The user than has to find the downloaded file and open it, in order to see it. It is also possible that the user does not even realize that the requested file has downloaded. Here is an example of the pertinent code that I am using:
aware of those difficulties, and are able to <a href="2c52d14e1brf.pdf" target="_blank">help steer applicants through these rocky shoals</a>.
Is there a way to force the linked file to open (assuming, of course, that the visitor has .pdf software)?
jscheuer1
02-02-2018, 04:12 AM
I did that both on my localhost server and on my domain. The file doesn't download. It displays in a new tab in the browser. I think this is set in the browser, but might be set on the server. Try my example and see what happens:
http://jscheuer1.com/demos/tidbits/dlpdf.htm
Here's my page's code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<a href="some.pdf" target="_blank">Some PDF</a>
</body>
</html>
In any event, I think the trick is to force a download when the browser is configured to display the file. But I could be mistaken. I tried all major browsers, they all displayed the file.
marain
02-02-2018, 01:44 PM
John,
Thanks for your answer. (Glad to see you're still here upon my own return after a palpable absence.)
As best I can tell, your html code appears functionally equivalent to mine. For some reason, I see a difference in action between your code and mine. (That would tend to rule out server setting.) Your code opens a new tab in the browser, containing a link to your .pdf file. The file itself downloads only when I click on the link in the new tab. With my code, a new tab opens momentarily then after about a half second, disappears. The .pdf file itself downloads. It opens only when I click on it.
I'm missing something.
A.
jscheuer1
02-02-2018, 02:52 PM
Wait a second, you're saying that basically the same code on my server does what you want, and that when it is on your server it doesn't do what you want? If that's what you're saying, then it's most likely some server configuration. But I didn't think that was possible, I thought to force a pdf download you needed a special page with the download headers. I'm not really up on all the latest with this though, or even all the oldest.
Anyways, if you get one result on one server (mine), and a different result on a different server (yours) with the same HTML code and the same browser, then it's probably the server. The only other things I can think of are headers (is your page PHP?), or possibly doctype or meta tags.
However, if you're only testing your code on the hard drive, that might be the explanation - Browsers often react differently to code that is not live.
marain
02-02-2018, 03:16 PM
These are .php files, and I've tried it only using the server, and only using FF 58.0.1 (32 bit). The page in question is https://www.njexpungements.com/faq.php. An area that demonstrates the situation I've been describing is the last two paragraphs of the answer to Question 30. Clicking on the links to .html files opens a new window (nothing strange there). Clicking on the link to a .pdf file behaves as indicated in my earlier posts.
Were I overlooking something obvious or easily discerned, I would have made the necessary changes. As it is, the problem is insufficiently irksome for me to delve more deeply. I am prepared to accept your surmise that the explanation lies within the server.
A.
jscheuer1
02-02-2018, 06:10 PM
Well I don't have that version of Firefox. I have 57.0 (64 bit). And in it and all other major browsers your link opens in a new tab as desired. So it's likely the browser. It may be set to download PDF of a certain size and larger. It is a pretty sizable PDF file. In any case, I would hazard most users have it open for them in a new tab.
Oh, and just updated to Firefox 58.0.1 (64 bit) also fine in that.
molendijk
02-05-2018, 05:05 PM
John and Marain, I also have FF 58.0.1 (32 bit), but with this browser-version, the PDF does not behave here like Marain says. The PDF-file opens and stays there, waiting for a click on it to be downloaded.
To avoid PDF-issues related to the use of certain browsers or Operating Systems, I always use the Google Document Viewer for displaying PDF, see this (http://mesdomaines.nu/eendracht/pdf_embed_or_newwindow_newtab/pdf_embed_or_newwindow_newtab.html).
Edit: I may have misunderstood the question. If so, please remove my post.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.