123456789101112131415161718192021222324 |
- var fnz = (function () {
- return {
- getEl: function (id) { return document.getElementById(id); },
- scrollIntoViewById: function (id) { fnz.getEl(id).scrollIntoView(true); },
- downloadFile: function (filename, contentType, content) {
- // Create the URL
- const file = new File([content], filename, { type: contentType });
- const exportUrl = URL.createObjectURL(file);
- // Create the <a> element and click on it
- const a = document.createElement("a");
- document.body.appendChild(a);
- a.href = exportUrl;
- a.download = filename;
- a.target = "_self";
- a.click();
- // We don't need to keep the object URL, let's release the memory
- // On older versions of Safari, it seems you need to comment this line...
- URL.revokeObjectURL(exportUrl);
- a.remove();
- }
- }
- })();
|