|
Posted by Benjamin Niemann on 10/17/70 11:49
Herman wrote:
> Is it illegal to define your own attributes that are not defined by
> HTML standards?
You won't go to jail for it, but it is invalid.
> It sounds stupid, but would this work:
>
> <td id='cell' info='Information stored here'>
I would not call it 'info', chances are to high that this will clash with
future HTML versions (ha ha) or browser specific extensions. Call it
e.g. 'xHermanInfo' (a more conventional 'x-herman-info' would be allowed as
an attribute, but will cause trouble in JS...)
> Then in javascript:
>
> var info = document.getElementById('cell').info;
This may or may not work. Browsers are free to ignore tags and attributes
that they do not understand, so your info attribute may not end up in the
DOM. Hey, but this is JavaScript, so you write your scripts anyway in a way
that degrades gracefully, if required features are not available... You do?
> The attribute wouldn't have an effect on the element itself, but it
> would act as an information holder for the particular element.
> This idea to me screams conflict with W3 standards, but its an idea
> that would seemingly make things easier for me.
> Any thoughts?
> Thanks a lot.
You can get the same (if the information is always accessed by the elements
ID) by using a JavaScript array that maps 'cell' -> 'Information stored
here'.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
Navigation:
[Reply to this message]
|