14 lines
446 B
JavaScript
14 lines
446 B
JavaScript
|
window.DownloadFile = function (fileName, content) {
|
|||
|
const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
|
|||
|
const url = URL.createObjectURL(blob);
|
|||
|
|
|||
|
const a = document.createElement("a");
|
|||
|
a.href = url;
|
|||
|
a.download = fileName;
|
|||
|
document.body.appendChild(a);
|
|||
|
a.click();
|
|||
|
|
|||
|
// Po stisknutí tlačítka, odstraníme element a URL objekt
|
|||
|
document.body.removeChild(a);
|
|||
|
URL.revokeObjectURL(url);
|
|||
|
};
|