Tag: ExplorerCanvas

Using dynamic canvas creation with google excanvas using IE

When you are using IE and ExplorerCanvas, dynamically created canvas with document.createElement are not working. They’re are not extending the ExplorerCanvas functionnality by default.

Include this script after excanvas.js in your html header to extend the created element at creation:

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}

Now you’re dynamically created canvas will actually work. This is surelly not the best way to do it, because of performance overhead, but at least it works. Plus, you rarely use tons of canvas in the same document.

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}