diff --git a/create-circle.js b/create-circle.js index 7eb4e15..13c56b9 100644 --- a/create-circle.js +++ b/create-circle.js @@ -196,8 +196,17 @@ function httpRequest(url, callback, callbackVal=null) } function downloadImage(){ - var link = document.createElement('a'); - link.download = 'mastodon-circle.png'; - link.href = document.getElementById('canvas').toDataURL() - link.click(); + var lnk = document.createElement('a'), e; + lnk.download = 'mastodon-circle.png'; + lnk.href = canvas.toDataURL("image/png;base64"); + + 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"); + } } \ No newline at end of file