You'll have to create your own wrapper around createElement that
initializes the canvas element for you. From the name of the patches
version you where using before I assume that's what it does.
Copy the createElement wrapper from that version
(DynamicInitializationCanvas.zip) into your script and you should be all
set.
--
Emil A Eklund
e...@eae.net
> This works fine:
> window.G_vmlCanvasManager.initElement( $(document.createElement
> ('canvas')).appendTo(document.body).get(0) )
>
> This fails:
> window.G_vmlCanvasManager.initElement( $('<canvas/>').appendTo
> (document.body).get(0) )
I'm noticing similar weirdness using the Prototype library and its
element creation syntactic sugar.
This works:
canvas = document.createElement('canvas');
canvas.id = 'my_canvas';
if (Prototype.Browser.IE) {
G_vmlCanvasManager.initElement(canvas);
canvas = $(canvas.id);
}
This fails:
canvas = new Element('canvas');
canvas.id = 'my_canvas';
if (Prototype.Browser.IE) {
G_vmlCanvasManager.initElement(canvas);
canvas = $(canvas.id);
}
> On Dec 23, 10:54 pm, Ryan Schmidt wrote:
>
>> if (Prototype.Browser.IE) {
>
> It's a bad idea to use browser sniffing here. Instead, why not check
> for a presence of `getContext` method on canvas element?
I too am a proponent of functionality testing instead of browser
sniffing, however is it guaranteed that every browser that is missing
the getContext method also supports VML? I think it's only IE that
has VML, hence the IE browser test. Not to mention that excanvas.js
is included in my page via IE conditional comments which only IE
understands, and of course that ExplorerCanvas is designed
specifically for Internet Explorer.
Anyway the point I was trying to make is that Prototype's "new Element
('canvas')" doesn't work (just like Jarred reported that jQuery's "$
('<canvas/>')" doesn't work) while the standard
"document.createElement('canvas')" does work.