ai-tube / src /lib /triggerDownload.ts
jbilcke-hf's picture
jbilcke-hf HF staff
🍿
1f122c3
raw
history blame
383 Bytes
export function triggerDownload(filename: string, text: string) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}