Pergunta

I have a simple HTML file which references .gadget so that it can be downloaded:

<a href="name.gadget">Download me!</a>

IE, Opera, Safari and Chrome all offer saving file to disk, however Firefox loads binary file in a tab. Why does Firefox hate me and what must I do to force Firefox to offer download dialog?

I don't really want to instruct users to "right-click and choose 'save file as'", or that they have to remove .zip extension after downloading.

Server is Apache/2.2.17, in case that it's relevant. Interesting fact is that Firefox does behave like all other browsers - if I load open .html file from local disk. But once it's on the server, it loads file in a tab.

Foi útil?

Solução

So, here's the solution.

The problem is that Apache returns Content-Type=text/plain HTTP header by default for all "unknown" file types. Firefox adheres to the standards unlike all other browsers so it displays the content. Here's what they have to say about it. You can inspect header in Firefox with Firebug (or simply use curl if you're on Unix).

The above link also hints the solution; register application/x-windows-gadget MIME type with the server. If you don't have access to the server configuration, put .htaccess file in the same directory as your file (or in any of the directories above your directory) with the following line:

AddType application/x-windows-gadget .gadget

After that, don't forget to clear your browser cache.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top