dinamic canvas ugly head in IE8

111 views
Skip to first unread message

radu

unread,
Nov 20, 2009, 7:25:02 AM11/20/09
to google-excanvas
I've been using excanvas v2 for a while and it worked well, even if I
created the canvas dinamically, using initElement afterwards. But v2
is not working on IE8, so I wanted to upgrade to v3. Now if I create
the canvas dinamically, and try to initElement:

G_vmlCanvasManager.initElement(canvas)
or
canvas = G_vmlCanvasManager.initElement(canvas)

I get the same err: "Unexpected call to method or property access." on
this line:
surfaceElement.appendChild(el);

I checked this group but I didn't see any real fix for this. Has
anybody have any ideas?

Fabien

unread,
Nov 20, 2009, 7:29:38 AM11/20/09
to google-excanvas
Hello, could you try with the latest version here :
http://code.google.com/p/explorercanvas/source/browse/trunk/excanvas.js

The downloadable file is here : http://explorercanvas.googlecode.com/svn/trunk/excanvas.js

Fabien

radu

unread,
Nov 20, 2009, 8:24:20 AM11/20/09
to google-excanvas
Fabien, I get the same error.

Dean Edwards

unread,
Nov 20, 2009, 9:13:23 AM11/20/09
to google-...@googlegroups.com
On 20/11/2009 13:24, radu wrote:
> Fabien, I get the same error.
>

Provide a test page.

-dean

Fabien

unread,
Nov 20, 2009, 9:15:46 AM11/20/09
to google-excanvas
You are probably calling initElement on a canvas which is not yet
inserted into the document, or before the document is loaded.

But as Dean said, a test page is welcome !

radu

unread,
Nov 20, 2009, 9:32:19 AM11/20/09
to google-excanvas
I'm gonna build a test page. Still since it worked on excanvas v2, I
don't think it's a problem with the canvas not being loaded into DOM.
When clicking on a link, I make an ajax call, get the result (a div
with lots of canvas inside), append that div to the body and after
that I do initElement. So document is loaded, canvas elements are
loaded.
So you guys say that this scenario should work? I thought it's a
common problem, because I saw that error on google search but nobody
came up with a solution.

radu

unread,
Jan 5, 2010, 7:53:50 AM1/5/10
to google-excanvas
Sorry for taking so long, here's the test page (jquery 1.3.2 &
excanvas 3). If you click "GO" you'll see the error.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="excanvas.js?v=3"></script>
</head>

<body>

<script>

function fa(){
var div = document.createElement("div");
div.id = "div";
div.innerHTML = "<div id='results'>R:<canvas id='canvas' width='200'
height='200'></canvas><canvas id='canvas2' width='200' height='200'></
canvas></div>";
$("#box")[0].appendChild(div);

var c = $("#canvas")[0];
alert(c);

if (!c.getContext){
c = G_vmlCanvasManager.initElement(c);
}

var ctx = c.getContext("2d");
ctx.strokeStyle = 'black';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(200,200);
ctx.closePath();
ctx.stroke();
}

</script>

<a href="#" onClick="fa()">GO</a>
<div id="box"></div>

</body>

</html>

radu

unread,
Jan 5, 2010, 8:00:50 AM1/5/10
to google-excanvas
PS: If I create the canvas with createElement it's ok, the problem is
when you put the canvases in a div with innerHTML: div.innerHTML =
"<canvas ...></canvas>"
Reply all
Reply to author
Forward
0 new messages