Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

Control view and download links separately

  • 4 réponses
  • 1 a ce problème
  • 1 vue
  • Dernière réponse par James6M

more options

Some sites offer separate links for viewing and downloading. (I'm specifically interested in PDF files, but I think this question is more general.) I'm not sure how this distinction is communicated to Firefox—I'm guessing in the MIME type? But regardless of the mechanism, Firefox does not seem to offer any obvious settings that distinguish between the two cases. Are there ways to distinguish in less obvious places, such as about:config?

As a specific example: currently on a certain site when I click "View" the PDF is displayed in Firefox, and when I click "Download" the PDF is both placed in my Downloads folder and displayed in Firefox. I would prefer that the "Download" link only cause the download, and not cause the display. How can I change this without breaking the "View" links?

Some sites offer separate links for viewing and downloading. (I'm specifically interested in PDF files, but I think this question is more general.) I'm not sure how this distinction is communicated to Firefox—I'm guessing in the MIME type? But regardless of the mechanism, Firefox does not seem to offer any obvious settings that distinguish between the two cases. Are there ways to distinguish in less obvious places, such as about:config? As a specific example: currently on a certain site when I click "View" the PDF is displayed in Firefox, and when I click "Download" the PDF is both placed in my Downloads folder and displayed in Firefox. I would prefer that the "Download" link only cause the download, and not cause the display. How can I change this without breaking the "View" links?

Toutes les réponses (4)

more options

Hi James6M, there are multiple factors here, and some of these issues are specific to PDFs.

Historically, with the default setting of "Open in Firefox" for PDFs, Firefox would cache a PDF as web content and display it in the built-in viewer if two things were true:

  • The server set the Content-Type header to "application/pdf"
  • The server did NOT set the Content-Disposition header to "attachment"

Thus, sites had two methods to bypass viewing of PDFs in a tab so they could force a download, setting attachment disposition and using a non-confirming MIME type. Over time, based on complaints from Firefox users about inconsistent behavior of "Open in Firefox" for PDFs, Mozilla started to make changes:

Content-Disposition: attachment

Starting in Firefox 98, if users have "Open in Firefox," instead of displaying the Open/Save/Cancel dialog, Firefox auto-saves the PDF in the "Save files to:" folder (usually Downloads) and then opens the PDF in a tab. Firefox 102 added a preference to use the system Temp folder instead (the browser.download.start_downloads_in_tmp_dir preference in about:config, which is for all downloads, not just PDFs).

Starting in Firefox 103, if users have "Open in Firefox," they can override attachment disposition completely, so Firefox caches the PDF as web content (thus showing the original URL in the address bar instead of the local file:// URL). This is the browser.download.open_pdf_attachments_inline preference in about:config.

Content-Type: other

Sites that were bypassing viewing in a tab by assigning the generic Content-Type: application/octet-stream type, without changing the .pdf file extension, could no longer leverage this technique as of Firefox 103. Some more exotic/fictitious content-type (such as application/forced-download) might still work.

What can end users do?

The simplest option, if it's available, is to right-click the link to the PDF and use Save Link As to call up a Save As dialog. This allows you to control where the file is saved on your computer.

For sites that use a button rather than a link, unfortunately, I can't think of a quick workaround. I might be able to update my Content-Type Fixer extension to resolve it, but I haven't been able to work on it lately.

more options

Whoa, so much information. I had to make a 4th-order truth table. It sounds like I was wrong, and that PDFs are a special case. So, focusing there:

Nearly all sites that I care about serve the PDFs through something other than a simple link, so "Save Link As" is not an option. I suppose this is a security thing (financial institutions). But regardless, I still hope to not need a work-around to make a link that says "Download" to actually result in a download.

If I parsed the info correctly, then setting Settings> Applications> Content Type> PDF to "Open in Firefox" will result in PDFs always displaying in a Firefox tab or window after download. The various server and about:config options only affect where that data is saved before display occurs. (This is barring the server doing something exotic, which the user has no control over anyhow.)

The behavior I seek would display the PDF only sometimes. So the question becomes, is there any configuration in which Settings> Applications> Content Type> PDF is not "Open in Firefox," and yet PDFs will sometimes be displayed in Firefox?

more options

If you change the setting for PDFs to "Always ask" then Firefox will offer the option of whether/where to open the PDF or to simply save it. With this setting, the PDF is always considered a download and saved externally whichever option you choose.

more options

I was hoping that there were a settings choice so that clicking a "View" link results in viewing the document, and clicking a "Download" link results in downloading the document (only). I'm now gathering that with the current version of Firefox, that is completely impossible, regardless of choices of either the server or the user.

Unfortunate. But at least I will now stop chasing unicorns.