0

I have an interesting problem with download table as jpeg. My code is:

              html2canvas(document.getElementById("planety_table"), {
                onrendered: function(canvas) {
                document.getElementById('myImg').src = canvas.toDataURL("image/jpeg");
                var a = document.createElement('a');
                a.href = document.getElementById('myImg').src;
                a.download = "tabulka_planety.jpg";
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
              }
           });

In notebook, this code working fine. In Huawei phone too. But in Samsung Galaxy phone not - only when I make one touch to display after the button is clicked. Can you help me with this problem?

Thanks, best regards

  • You are programmatically clicking a link where there is no interaction by the user. It may be that the Galaxy is preventing this, for security reasons, and waiting for a user action. – DeeGee Jan 01 '23 at 12:24
  • What are you trying to do? Is it a download / opening of the generated *.jpg? If so, you might want to look into doing this with blobs. For example, [like it's shown here](https://stackoverflow.com/questions/44567511/downloading-canvas-image-using-toblob). This would circumvent the potential permission issues on various devices, like @DeeGee mentioned. – FiddlingAway Jan 01 '23 at 13:16

0 Answers0