1var val = "<div>abc</div>";
2
3var file = new Blob([val], {
4 type: "text/html"
5});
6// file object reference
7var download = URL.createObjectURL(file);
8
9var a = document.createElement("a");
10a.href = download;
11a.download = "file-" + new Date().getTime();
12document.body.appendChild(a);
13a.click()