Devang
Devang

Reputation: 1541

createElement('canvas') code works on Safari but not on Firefox, Chrome

I am trying a simple query which gets an image, and loads its data into a variable. This code works on Safari(5), but doesn't work on Firefox(3.6.3 for Mac) or Chrome(10 for Mac).

Here's the code: http://jsfiddle.net/saTzx/

Any idea what could be going wrong?

Another question related to this code is, shouldn't drawImage() actually draw the image? This doesn't happen in any of the browsers.

Upvotes: 0

Views: 1612

Answers (1)

Eli Grey
Eli Grey

Reputation: 35895

The image is drawn, you just never appended the canvas to any parent element (e.g. document.body.appendChild(canvas)).

I get "Failed to load image" (also, that isn't the real error, the image is loaded) in Safari too, and rightly so. You are trying to read image data tainted by an image without any appropriate CORS headers, which is the source of your error. Fix your headers.

Upvotes: 1

Related Questions