Is IE 8 Support Totally broken?

1,364 views
Skip to first unread message

tazz_ben

unread,
Mar 10, 2010, 6:32:32 PM3/10/10
to google-excanvas
So I was doing a basic test to present as a potential solution to
client and I wanted to show just that an image could be rotated and
with excanvas it would work on IE. While this code works on other
platforms, on IE 8, the Microsoft developer tools throws an error when
I try to access "getContext". Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!--[if IE]>
<script type="text/javascript" src="excanvas.js"></script>
<![endif]-->

</head>
<body>
<canvas id="testimage" width="150" height="150"></canvas>
<script type="text/javascript">
var canvasimage = {};

canvasimage.canvas = function (canvasid){
var canvasid = canvasid || "testimage";
var canvas = document.getElementById(canvasid);
var ctx = canvas.getContext('2d');
return ctx;
}();

canvasimage.loadpng = function (){
var img = new Image();
img.onload = function(){
canvasimage.canvas.drawImage(img,0,0);
};
img.src = 'test.png';
return img;
}();

canvasimage.rotate = function(degree){
canvasimage.canvas.rotate(Number(degree) * Math.PI / 180);
};

canvasimage.rotate(15);
// canvasimage.rotate(-15);
</script>
</body>
</html>

Please tell me I'm missing something, without the getContext method,
I'm not sure how excanvas has much value.

Fabien

unread,
Mar 12, 2010, 4:43:09 PM3/12/10
to google-excanvas
Yep, you are missing something : reading the docs ;)
http://code.google.com/p/explorercanvas/wiki/Instructions
And sometimes, the initElement needs to be called even when the canvas
tag already exists. There are also a few differences with the native
implementation.

Aseem Kishore

unread,
Mar 12, 2010, 5:00:12 PM3/12/10
to google-...@googlegroups.com
I'm guessing this is because <canvas> elements in the HTML are automatically initialized -- but that's once the page loads ("document ready"), while your script is executing -- and using that <canvas> before the page has finished loading.

Aseem

--
You received this message because you are subscribed to the Google Groups "google-excanvas" group.
To post to this group, send email to google-...@googlegroups.com.
To unsubscribe from this group, send email to google-excanv...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-excanvas?hl=en.


Reply all
Reply to author
Forward
0 new messages