当前,我正在使用以下代码创建文本文件:
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”。
“类型”值应该是什么?
答案 0 :(得分:0)
var text = "this is the content";
var name = "myfilename.txt";
var type = "text/html";
var a = document.getElementById("a");
a.style.display = "block";
var file = new Blob([text], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;