为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

PDFs are opening in browser AND downloading

more options

In my Firefox settings, I have PDF files set to "Open in Firefox".

When I click on a PDF file, Firefox DOES open the PDF in a new browser tab, but the PDF ALSO downloads to my desktop (both!). How can I stop it from downloading?

In my Firefox settings, I have PDF files set to "Open in Firefox". When I click on a PDF file, Firefox DOES open the PDF in a new browser tab, but the PDF ALSO downloads to my desktop (both!). How can I stop it from downloading?

由gtg254k于修改

被采纳的解决方案

If you don't want the PDF in your Temp folder, either, Firefox 103 added a new option to store it in the browser cache.

(3) New Content-Disposition Override

When a server sends a PDF, it can optionally send a Content-Disposition header (MDN). This header can indicate either "inline" or "attachment".

  • "inline" refers to displaying in the browser
  • "attachment" refers to downloading

This is invisible to you but explains why some PDFs open normally with their web address (inline) and some save to disk and open in a new tab with a file:/// address (attachment) after being saved to disk.

GOOD NEWS: Firefox 103 now has a new feature to override Content-Disposition: attachment for PDFs, making Firefox treat them all as web content (inline). If you prefer to use Firefox as your PDF viewer, then this should be helpful:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future. I'm using this so I feel comfortable mentioning it.

(b) In the search box in the page, type or paste browser.download.open_pdf_attachments_inline and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

Success?

定位到答案原位置 👍 2

所有回复 (3)

more options

PDF files need to be downloaded for Firefox to be able to read them for the PDF viewer.

more options

Firefox 98 made a lot of changes to how PDFs open. The two big ones are:

(1) Skipping the download dialog

Firefox 97 and earlier would present a download dialog if the server tried to bypass the viewer by forcing a download (Content-Disposition: attachment). If you have "Open in Firefox", Firefox now skips the dialog and behaves as though you had clicked "Open with Firefox" in that dialog. In other words, it saves the file to disk and then opens it.

(2) Saving files in the "Save files to" folder instead of your Windows Temp folder

Firefox 98 changed from saving downloads in the Windows Temp folder for "Open with [relevant application]" or "Use [relevant application]" to saving them in your default downloads folder (the one next to "Save files to" on the Settings page). It's not possible to pass a file to an application without saving it somewhere.

Firefox 102 added a hidden setting to roll back that change. Here's how you access it:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future.

(b) In the search box in the page, type or paste browser.download.start_downloads_in_tmp_dir and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

more options

选择的解决方案

If you don't want the PDF in your Temp folder, either, Firefox 103 added a new option to store it in the browser cache.

(3) New Content-Disposition Override

When a server sends a PDF, it can optionally send a Content-Disposition header (MDN). This header can indicate either "inline" or "attachment".

  • "inline" refers to displaying in the browser
  • "attachment" refers to downloading

This is invisible to you but explains why some PDFs open normally with their web address (inline) and some save to disk and open in a new tab with a file:/// address (attachment) after being saved to disk.

GOOD NEWS: Firefox 103 now has a new feature to override Content-Disposition: attachment for PDFs, making Firefox treat them all as web content (inline). If you prefer to use Firefox as your PDF viewer, then this should be helpful:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future. I'm using this so I feel comfortable mentioning it.

(b) In the search box in the page, type or paste browser.download.open_pdf_attachments_inline and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

Success?