Merge pull request #173 from natecain/BlobAPI

Blob api
print-window-tiddler
Jeremy Ruston 2013-10-01 14:41:43 -07:00
commit 9616b5586f
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -28,7 +28,12 @@ DownloadSaver.prototype.save = function(text) {
// Set up the link
var link = document.createElement("a");
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);
document.body.appendChild(link);
link.click();