Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data

后端 未结 2 1569
太阳男子
太阳男子 2021-01-03 04:29

I am getting this error in Chrome and Opera Browsers:

Uncaught SecurityError: Failed to execute \'getImageData\' on \'CanvasRenderingContext2D\': The canvas          


        
2条回答
  •  一生所求
    2021-01-03 05:23

    When you load your html file from disk using: file://path/to/your/file.html, then Google Chrome and Opera will raise error at line including: imgData = ctx.getImageData(x1,y1,w,h);

    Solution is simple: start web server (apache, nginx) put your html file somewhere at web server and load your html file from: http://localhost/somewhere/file.html

提交回复
热议问题