【发布时间】:2020-10-23 22:10:53
【问题描述】:
我有以下代码:
function downloadNotes() {
var information = document.getElementById("text").innerHTML;
var textToBLOB = new Blob([information], { type: 'text/plain' });
var sFileName = 'formData = document.doc';
var newLink = document.createElement("a");
newLink.download = sFileName;
if (window.webkitURL != null) {
newLink.href = window.webkitURL.createObjectURL(textToBLOB);
}
else {
newLink.href = window.URL.createObjectURL(textToBLOB);
newLink.style.display = "none";
document.body.appendChild(newLink);
}
newLink.click();
}
当我保存我的笔记时,它成功地将它保存到 word,但是当我打开它时,它显示代码全部压缩而不是字符串输出: Here.
【问题讨论】:
-
text/plain表示不解析 HTML,只是按字面意思显示。
标签: javascript html ms-word download save