I am working with javascript + Raphael.js and would like to export the paper with JSON and download it as a text file by clicking a button.
I have already managed to export the paper with JSON due to raphael.json.js and save it as a string:
var json = paper.toJSON();
and I have also found something to download it as a text file:
var a = document.body.appendChild(
document.createElement("a")
);
a.download = "export.txt";
a.href = "data:text/plain;base64," + btoa(json);
a.innerHTML = "download example text";
but unfortunately only by creating a link instead of clicking a button and I have no idea how to manage that.
Thank you in advance!