Page 1 of 1

Help. Problem with canvas.

PostPosted: Sun Jan 17, 2016 1:15 am
by anton
I am trying to open an image from the canvas as follows:
Code: Select all
var canvas = document.getElementById("test-canvas");
window.open(canvas.toDataURL("image/png"),"tfract_save");

In the console, I get the following error:
Code: Select all
SecurityError


If anyone know what is wrong ?

Re: Help. Problem with canvas.

PostPosted: Sun Jan 17, 2016 4:36 am
by Tony Kroos
Looks like it's a "cross-origin" security error.
Although you can use images without CORS approval in your canvas, doing so taints the canvas. Once a canvas has been tainted, you can no longer pull data back out of the canvas. For example, you can no longer use the canvas toBlob(), toDataURL(), or getImageData() methods; doing so will throw a security error.

This protects users from having private data exposed by using images to pull information from remote web sites without permission.

Read more here.

Re: Help. Problem with canvas.

PostPosted: Sun Jan 17, 2016 10:23 am
by anton
Tony Kroos wrote:Looks like it's a "cross-origin" security error.
Although you can use images without CORS approval in your canvas, doing so taints the canvas. Once a canvas has been tainted, you can no longer pull data back out of the canvas. For example, you can no longer use the canvas toBlob(), toDataURL(), or getImageData() methods; doing so will throw a security error.

This protects users from having private data exposed by using images to pull information from remote web sites without permission.

Read more here.

Ok... Thank you so much.