I can do something like this:
// function definition
document.foo = function(bar){alert(bar);}
// function call
document.foo(3); // messagebox that outputs '3'
However, I want to prototype something similar for all document objects/elements (tables, input boxes, etc).
The following doesn't work:
// don't work
Object.foo = function(bar){alert(bar);}
document.Object.foo = function(bar){alert(bar);}
// works for new Object()
Object.prototype.foo = function(bar){alert(bar);}
var obj = getElementById('ElementsID'); // typeof obj == "object"
obj.foo(2); // doesn't work
var obj = new Object();
obj.foo(3); // does work
Prototyping only works on new objects created by the Objects() class, but not document objects, or those objects that already exist. I'm not exactly sure how to event reference the document.[object collection]
I've tried to search the net, but the 'Prototype' package returns more hits than the prototype method/attribute. If anyone knows how to do this, I would be very grateful.
Thank you,
vol7ron
.