0
 function save() {
    document.getElementById("canvasimg").style.border = "2px solid";
    var dataURL = canvas.toDataURL();
    document.getElementById("canvasimg").src = dataURL;
    document.getElementById("canvasimg").style.display = "inline";
}

wich will creat a new picture to the right but i want it to download right away i think you would have to use

<a href="x" download>

but what would x be for the download and how would i set it to download on click

The Comment

Does this answer your question? Download data URL file – Harshit Rastogi

i tried to use that code but it says it has an error trying to download im using github so i think it tried to download the site i made. The error in the bottom right

here is the website ive been trying for it to work its a little messy but in the middle is the drawing https://bobzilla07.github.io/web-platform-j1pnv3/

4
  • 2
    It would be the data URL. You can create the a tag dynamically (doesn't even have to be visible), set its src as well as a download attribute, and call .click() on it to trigger the download synthetically.
    – CherryDT
    Commented Sep 23, 2021 at 14:05
  • so would it be <a href="dataURL" download> ?
    – Bobzilla07
    Commented Sep 23, 2021 at 14:07
  • 2
    Does this answer your question? Download data URL file Commented Sep 23, 2021 at 14:07
  • No, not statically a string called dataURL. It would have to be set dynamically at runtime (using setAttribute or your framework's method of choice, if any).
    – CherryDT
    Commented Sep 23, 2021 at 14:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.