Bugfix for Download Function

This commit is contained in:
Andreas Grasser 2022-11-28 18:19:11 +01:00
parent bd469cbd11
commit 8ac873d481
No known key found for this signature in database
GPG key ID: A6A70D76EF291D77

View file

@ -196,8 +196,17 @@ function httpRequest(url, callback, callbackVal=null)
} }
function downloadImage(){ function downloadImage(){
var link = document.createElement('a'); var lnk = document.createElement('a'), e;
link.download = 'mastodon-circle.png'; lnk.download = 'mastodon-circle.png';
link.href = document.getElementById('canvas').toDataURL() lnk.href = canvas.toDataURL("image/png;base64");
link.click();
if (document.createEvent) {
e = document.createEvent("MouseEvents");
e.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false,
false, 0, null);
lnk.dispatchEvent(e);
} else if (lnk.fireEvent) {
lnk.fireEvent("onclick");
}
} }