javascript - HTML 下载的文件类型不正确

标签 javascript html

我正在尝试在我的 html 上添加下载链接。但是当我下载文件时,文件扩展名不正确。它只是显示 File 而不是 csv 文件类型。

<a href="test.csv" download="filename">Download link</a>           

我做错了什么?

最佳答案

The download attribute specifies that the target will be downloaded when a user clicks on the hyperlink.

This attribute is only used if the href attribute is set.

The value of the attribute will be the name of the downloaded file. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).

If the value is omitted, the original filename is used.

https://www.w3schools.com/tags/att_a_download.asp

<a href="test.csv" download>Download link</a>

关于javascript - HTML 下载的文件类型不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48178221/

相关文章:

javascript - 为什么这个 jQuery 插件(Tooltipster)的 Ajax 内容只有在鼠标悬停 2 次后才显示?

javascript - 编码 HTML 和 JavaScript

html - Microsoft Edge 阅读 View 多列 CSS

html - 在单独的页面上打印多个 div

javascript - 使用 Blazor 重写 JavaScript 单击和显示 UI

javascript - 直接从应用程序中删除mac electronic应用程序时如何清除用户数据?

javascript - 如何将警报附加到音频,javascript

javascript - ExtJs 4 ViewPort 与带有边框布局的面板 - 使用哪个以及为什么?

php - 无需单击按钮即可添加

javascript - 如何使用标题和标签更好地格式化我的 HTML 表