Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72358

Crossover Origin Attribute JS/HTML

$
0
0

Basically, I'm writing a program that allows a user to create and export maps. I can't get JavaScript to export the map (a canvas) because it is "tainted." I tried looking this up and tried to fix the error multiple times in multiple ways, but nothing worked. Here is some of the code for exporting in case it helps:

<img id="exportImage" crossorigin="Anonymous">


<script>

     function exportMap(){
       var canvas = document.getElementById('canvas');
      var context = canvas.getContext('2d');
      var img = document.getElementById("exportImage")

      // save canvas image as data url (png format by default)
      img.crossorigin = "Anonymous";
      var dataURL = canvas.toDataURL();
      console.log(dataURL)
      document.getElementById("exportImage").src = dataURL;
      }

 </script>

Thanks in advance!


Viewing all articles
Browse latest Browse all 72358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>