Screenshot button of frame

Explorer ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

In my online html5 canvas game I want the user to be able to download the score of the game as an image. In the forum I've found a script that works very good!

 

_this.DownloadReset.SaveImage.on('click', function(){
var aTag = document.createElement('a');

aTag.setAttribute('href', canvas.toDataURL("image/png"));

aTag.innerHTML = "Download";

aTag.download = "This_is_your_story.png";

document.body.appendChild(aTag);
});

 

But I actually want the user to download it with a button within my interface. This shows a download text outside of the div. Is there a easy fix for that? Instance name of my button is "SaveImage".

 

Screenshot 2021-03-24 at 15.33.35.png

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Mar 24, 2021 Mar 24, 2021
_this.DownloadReset.SaveImage.on('click', function(){ var aTag = document.createElement('a'); aTag.setAttribute('href', canvas.toDataURL("image/png")); aTag.innerHTML = "Download"; aTag.download = "This_is_your_story.png"; aTag.click() });

Likes

Translate

Translate
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

 

 

_this.DownloadReset.SaveImage.on('click', function(){
var aTag = document.createElement('a');

aTag.setAttribute('href', canvas.toDataURL("image/png"));

aTag.innerHTML = "Download";

aTag.download = "This_is_your_story.png";

aTag.click()
});

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Fantastic. thank you for your swift reply!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines