mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
add IE11 polyfill to support URI download scheme
This commit is contained in:
parent
f5da2eb633
commit
3740c21bee
@ -53,5 +53,31 @@
|
|||||||
Set.prototype.constructor = Set;
|
Set.prototype.constructor = Set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window.navigator.msSaveBlob) {
|
||||||
|
// IE does not support data uri scheme for downloading data
|
||||||
|
window.addEventListener("click", function (ev) {
|
||||||
|
var tgt = ev.target;
|
||||||
|
if ((tgt.tagName === "A") &&
|
||||||
|
tgt.hasAttribute("download") &&
|
||||||
|
tgt.hasAttribute("href")) {
|
||||||
|
// partial support of data uri downloading
|
||||||
|
var filename = tgt.getAttribute("download");
|
||||||
|
var dataUri = tgt.getAttribute("href");
|
||||||
|
var match = /^data:([^,]+),(.*)/.exec(dataUri);
|
||||||
|
if (match) {
|
||||||
|
ev.preventDefault();
|
||||||
|
var enc = match[1];
|
||||||
|
var data = decodeURIComponent(match[2]);
|
||||||
|
var blob = new Blob([data], {
|
||||||
|
type: enc,
|
||||||
|
});
|
||||||
|
navigator.msSaveBlob(blob, filename);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("download not supported:", tgt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user