开发者

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

开发者 https://www.devze.com 2023-02-26 01:01 出处:网络
I am trying a simple query which gets an image, and loads开发者_C百科 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).

I am trying a simple query which gets an image, and loads开发者_C百科 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消