"jonjon" <j.********@wanadoo.fr> writes:
Is there any way of adding a property to an HTML element ?
Adding a property to one HTML element is simple. Just add it
elem.property = "foo";
I heard about the "prototype" method but it doesn't work for HTML elements
such as Images, or Paragraphs...
All Javascript objects have an internal link to a prototype object,
where properties are looked up if they haven't been set on the object
itself. There doesn't have to be a way to access the prototype object,
though. For arrays and objects, you can get to it as Array.prototype
and Object.prototype. There is no similar constructor for DOM HTML
elements.
(Actually, in Mozilla, the constructors Image and Option have
prototype properties, in IE they don't).
Netscape implements HTMLElement objects but it seems to me that no
equivalent exists in Internet Explorer ?? (I hate that browser :)
Any idea ?
I would add the property manually to all the elements I interact with.
I usually have a function that uses getElementById or document.all to
access an element. I add other properties there too if I need them.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'