【发布时间】:2019-08-25 13:02:18
【问题描述】:
目前,我正在使用此代码创建一个文本文件:
var text = "this is the content";
var name = "myfilename.txt";
var type = "text/plain";
var a = document.getElementById("a");
a.style.display = "block";
var file = new Blob([text], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;
现在,如果我想创建一个 HTML 文件,而不是创建一个 .txt 文件。我明白了,我需要更改“myfilename.html”。
“类型”值应该是什么?
【问题讨论】:
-
'text/html' 最有可能。你可以在谷歌上搜索更多的 mime 类型
标签: javascript html file