1

I try to export element to PNG image with Javascript, but I've the error message :

SecurityError: The operation is insecure.

I read on other forum, it's because the flag of my canvas is turn true. SO, do you know hwhere can I turn false the flag origin-clean ?

The button where I run my function :

<div id = "control_export_png">
  <a id="control_link_export_png" download="extrait_carte_cclo.png" style="display:block;" crossOrigin="anonymous">
  </a> 
</div>

And my javascript:

var exportPNGElement = document.getElementById('control_link_export_png');

if ('download' in exportPNGElement) {
    exportPNGElement.addEventListener('click', function(e) {

        map.once('postcompose', function(event) {

            var canvas = event.context.canvas;

            exportPNGElement.href = canvas.toDataURL();

         });

        map.renderSync();
     }, false);
}   
Sidius
  • 416
  • 1
  • 5
  • 24
Geo-x
  • 275
  • 1
  • 5
  • 22
  • Check this one out, might help http://stackoverflow.com/questions/8128118/get-security-error-when-saving-canvas-object-into-an-image – Asons Oct 30 '15 at 14:08
  • Hi LGSon, thank you but I read this subject and I don't found where can I giver the false value to my attribute. – Geo-x Oct 30 '15 at 15:21
  • Well you can't, the link explains why and how to solve. – Asons Oct 30 '15 at 15:48

0 Answers0