Dynamic creation and initialization canvas now in the current version
of the library excanvas.js:
var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;
// dynamical initialize canvas
if (/msie/i.test(navigator.userAgent))
{
canvas.id = "myCanvas";
document.body.appendChild(canvas);
G_vmlCanvasManager.initElement(canvas);
canvas = document.getElementById("myCanvas");
}
else
{
document.body.appendChild(canvas);
}
var ctx = canvas.getContext("2d");
ctx.fillRect(25, 25, 50, 50);
Dynamic creation and initialization canvas in a modified version of my
library excanvas.js:
var canvas = excanvas(document.createElement("canvas"));
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext("2d");
ctx.fillRect(25, 25, 50, 50);
document.body.appendChild(canvas);
Repro code: http://groups.google.com/group/google-excanvas/web/DynamicInitializationCanvas.zip