Offering Downloading
Sometimes you want to let the user download/export some text or image.
Lists of type
for Blobs: MDN Docs and iana media types
For any plaintext data formats, use ;charset=utf-8
.
function download(text){
const blob = new Blob([text], {type: 'image/svg+xml;charset=utf-8'});
const svgUrl = URL.createObjectURL(blob);
let downloadlink = document.createElement("a");
downloadlink.href = svgUrl
downloadlink.download = seed+".svg"
document.body.appendChild(downloadlink);
downloadlink.click();
document.body.removeChild(downloadlink);
}