zh******@gmail.com wrote:
I have check this newgroup by searching with "dom prototype".
It cannot work out with IE DOM object of bingding prototype on it.
You cannot make say "all HTML elements in this document have foobar()
method" in one assignment. But you can make say all div's in your
document draggable - in one assignment:
<style type="text/css"">
div {
behavior: url(draggable.htc);
/* for the exact link see MSDN link I gave you */
}
</style>
Pair with -moz-binding and you are done. Same way you can make say all
<address> block play music on click by default.
The medieval way is presented in two flawors:
The one you already know: create your own JavaScript objects with DOM
reference in it.
Another one is overload the constructor, so it would return the DOM
reference back after augmentation:
function xDIV(div) {
div.$ = this;
this.method1 = ...
this.method2 = ...
return div;
}
....
var d = document.createElement('DIV');
document.body.appendChild(new xDIV(d));
But it is indeed a medieval alchimie requiring manual node traversal
plus all neeeded and not needed code in one chunk.
As both bindings and behaviors are written in the conventiona
JavaScript/JScript I see no problem to use the recommended way.