1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00

Merge pull request #173 from natecain/BlobAPI

Blob api
This commit is contained in:
Jeremy Ruston 2013-10-01 14:41:43 -07:00
commit 9616b5586f

View File

@ -28,7 +28,12 @@ DownloadSaver.prototype.save = function(text) {
// Set up the link // Set up the link
var link = document.createElement("a"); var link = document.createElement("a");
link.setAttribute("target","_blank"); link.setAttribute("target","_blank");
link.setAttribute("href","data:text/html," + encodeURIComponent(text)); if(Blob != undefined) {
var blob = new Blob([text], {type: "text/html"});
link.setAttribute("href", URL.createObjectURL(blob));
} else {
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
}
link.setAttribute("download",filename); link.setAttribute("download",filename);
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();