--
erik
It could be changed to handle it transparently. I did this before in my
own humble attempt to build a Canvas/VML-Wrapper. It's possible to
overwrite the document.createElement Method. This custom Method can then
check if a "<canvas />" is going to be created. If not, then the
original createElement method is called. If yes, then the special
excanvas stuff can be called.
In this way it's handled transparently and all you have to do is
conditionally including the excanvas.js in your page.
I think I did it like this (Don't have the code anymore):
origCreateElement = document.createElement;
document.createElement = function(tagName)
{
var element = origCreateElement(tagName);
if (tagName == "canvas" || tagName.toLowerCase().indexOf("<canvas")
=== 0)
{
...Do excanvas initialization on element...
}
return element;
}
--
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger k...@ailis.de to get public key)
This makes at least four people who've suggested wrapping createElement
over the last 2 years including myself [1]. The admins don't seem to be
into the idea, but this continues to confound new users who're using new
canvas elements because there's no docs/example for it. FWIW, here's the
shortest code I can come up with:
var cv = document.createElement('canvas');
window.G_vmlCanvasManager && (cv = );
or faster if you plan to generate several:
var createCanvas = window.G_vmlCanvasManager
? function () {
return G_vmlCanvasManager.initElement(
document.createElement('canvas'));
}
: function () {return document.createElement('canvas');};
[1] http://groups.google.com/group/google-excanvas/msg/46d9645009827294
--
Steve Clay
http://mrclay.org/
Oops, that would of course be:
var cv = document.createElement('canvas');
window.G_vmlCanvasManager && (cv = G_vmlCanvasManager.initElement(cv));
I'm going to submit some new docs patches...
Ways to create elements:
createElement
innerHTML
outerHTML
document.write
insertAdjacentHTML
createNode
Ways to get elements
getElementsById
getElementsByTagName
getElementsByName
document.all
document.all.tags
childNodes
firstChild
lastChild
children
nextSibling
previousSibling
and probably a few more.
I have been experimenting with using expression to get the getContext
applied automagically but I need to spend more time on this.
> What is the license for excanvas? Can we fork this sucker off and
> start improving it?
That's ridiculous. ExCanvas allows you to do whatever you want with
it but it would be for a better good if people submitted patches on
head (not zip files of their modified ex canvas from 2 years ago).
Lately, I've really considered moving ex canvas to code.google.com
since source forge sucks. I'll post a seperate message covering that.
--
erik