2

Sometimes there are web URLs to raw program source files such as prog.c in the IOCCC. When viewed in Safari these are shown in plain text: Image However with Firefox I am unable to preview the file. Instead the file is saved to Downloads.

How can I disable this behavior? How can I preview URLs to raw program source files without downloading them in Firefox?

4
  • Safari downloads the file too, but then opens it. In fact, every time you visit a webpage, it is silently downloaded in the background and then being displayed. You can setup the default action for certain filetypes. If you set it to automatically open, you accomplish the same thing, although it may open it in an external program rather than in FireFox.
    – LPChip
    Commented May 26, 2023 at 7:25
  • @LPChip Well all browsers have to 'download' all data strictly speaking, but what I meant was saving the data to a file on my hard drive.
    – CPlus
    Commented May 26, 2023 at 16:45
  • Just wanted to make sure you understood this nuance. Some think that when a browser shows a file directly in the browser, that they are always using an online viewer. This does not have to be the case. The file can be downloaded to local temp or cache, and then opened externally in the browser, which is what safari does. Basically what Harrymc answered.
    – LPChip
    Commented May 26, 2023 at 17:27
  • @LPChip Another difference is the file being created transparently in some cache or temporary directory versus the file being saved to my downloads folder to stay there until I move or delete it.
    – CPlus
    Commented May 26, 2023 at 17:29

1 Answer 1

2

Firefox only offers to open files of types that are built-into it.

You may set Firefox to offer to open or save all the other types in Tools > Settings > General, under "Applications", by setting "Ask whether to open or save files". When being asked, you will then also have the option of "Always Open Similar Files" which will add this file-type to the list under Applications.

You may also set the "Always Open" option for a file-type from the Downloads panel or from the Library window Downloads history, by right-click on the file and selecting "Always Open Similar Files" from the context menu.

An extension that could help with this task is Open in Browser, described as :

This extension allows you to open the document directly in your browser.

Note that opening a file inside the browser would not always be truly inside the browser, but for some file-types may cause the file to be saved in a temporary location and then opened by the system application that is indicated by the file-type, if Firefox can't display it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .