A
A
Aleksandr2016-08-05 14:11:01
JavaScript
Aleksandr, 2016-08-05 14:11:01

Generating files from a piece of code?

Now a question arises. Is it possible (if so, how?) After generating the code, create a file and download it.
Here 's an example
When the button is clicked, a canvas is created. How can I download this picture?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Step, 2016-08-05
@Sashjkeee

var shotit = function() {
    html2canvas(document.body, {
      onrendered: function(canvas) {
        document.body.appendChild(canvas);

        var link = document.createElement("a");
            link.download = 'myImg.jpg';
            link.href = canvas.toDataURL('image/jpeg');
            link.click();
      }
    });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question