1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-26 00:46:52 +00:00

Only use the download saver when the download attribute is supported

This commit is contained in:
Jeremy Ruston 2012-11-16 19:31:32 +00:00
parent 80bd198908
commit a4d88769b9

View File

@ -23,10 +23,7 @@ DownloadSaver.prototype.save = function(text) {
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)); link.setAttribute("href","data:text/html," + encodeURIComponent(text));
// Use the download attribute to download it if it is supported
if(link.download !== undefined) {
link.setAttribute("download","tiddlywiki.html"); link.setAttribute("download","tiddlywiki.html");
}
link.click(); link.click();
return true; return true;
}; };
@ -36,14 +33,14 @@ Information about this saver
*/ */
DownloadSaver.prototype.info = { DownloadSaver.prototype.info = {
name: "download", name: "download",
priority: 0 priority: 100
}; };
/* /*
Static method that returns true if this saver is capable of working Static method that returns true if this saver is capable of working
*/ */
exports.canSave = function(wiki) { exports.canSave = function(wiki) {
return true; return document.createElement("a").download !== undefined;
}; };
/* /*