|
Posted by Andy Fish on December 5, 2006, 7:05 am
Please log in for more thread options
thanks andy (and others) for the replies
I guess the best solution in the general case would be to store extra stuff
in javascript structures indexed by element ids. I hadn't really thought of
this.
in this case, I just want to store a single extra string value alongside
some of the <a> tags, so I will use my own custom attribute.
Andy
>
> Andy Fish wrote:
>
>> I would like to include extra "hidden" information in a generated HTML
>> page
>> that can be used by javascript functions.
>
> Then put it in JavaScript.
>
>
>> I realise that most browsers seem to ignore any tags and attributes they
>> don't understand,
>
> No, they ignore unknown attributes. They will still process unknown
> tags (they show you their content) even if the "tag" appears not to
> have any effect. This behaviour is pretty reliable.
>
>
>> but from what I can tell the standards do not allow me to
>> make up my own tags or attributes as they will fail validation.
>
> You'll be able to do this cleanly with XML and namespacing, but that's
> still a long way off.
>
>> is there any standard element name that can be used for such a purpose
>
> In general, it's enough to use the existing elements and almost always
> to stick with the standard attributes too. You can achieve most of what
> you need with the class or id attributes. These values can then be
> lookup indexes into JavaScript arrays for more detail. You can even use
> anodyne elements like <div> or <span>, added where necessary just as
> carriers for these attributes.
>
> I'd happily add attributes if I really needed to, or it made the code
> clearer. I wouldn't add elements though.
>
|