如何在 Firefox 中下载 docx 文件而不是加载文件

How to download docx file rather than loading file in Firefox

Firefox 尝试读取 docx 文件而不是下载它们:

<a href="app/files/resources/downloads/Sample_Revision_Sheet.docx"
   target="_blank"> 
   Sample_Revision_Sheet.docx
</a>

您可以使用 download 属性,在 HTML5 中介绍:

This attribute, if present, indicates that the author intends the hyperlink to be used for downloading a resource so that when the user clicks on the link they will be prompted to save it as a local file. If the attribute has a value, the value will be used as the pre-filled file name in the Save prompt that opens when the user clicks on the link.

<a href="app/files/resources/downloads/Sample_Revision_Sheet.docx"
   download="Sample_Revision_Sheet.docx"> 
   Sample_Revision_Sheet.docx
</a>