extrabigmehdi
09-06-2006, 07:59 PM
hi,
I've been browsing the web for hours,
and wasn't able to answer to this question: what's wrong with using "non standard markups" (other would say invalid) for scripting purposes ?
I like the idea of storing dedicated attributes in a dedicated tag.
I've made a kind of popup script (not exactely a popup, but a lightbox-like (http://www.huddletogether.com/projects/lightbox/))
and here's how basically how it works.
Let's call the tag "darkbox"
So basically the code would be like:
<a href="link.htm">
<darkbox bottom="blue" title="my title" width="500" effect="zx" type="iframe" >
</darkbox>
</a>
I will initialize the page with an external js script , that will loop through all
the "darbox" tags.
It is pretty straightforward, I just have to do : document.getElementsByTagName("darkbox")
and then retrieve all these particular attributes using getAttribute.
After that , I can assign an onClick event to the parent tag which is a link .
Before you make an objection, you might ask why not put all attributes directely in the "a" link tag ?
First: I find the code easier to read
I keep attributes specific to the popup effect separate to "a" link tag.
Second: I don't want to conflict with existing valid attributes.
Special attributes stay dedicated to the popup effect.
Third: You may suggest the use of a class called "darkbox", and make a loop that check all span tags that have a class called "darkbox".
I would say then: the problem of non valid attributes remain.
Even if I put them in the "a" tag, the w3 validator (http://validator.w3.org/) will show errors.
Worst: with an invalid tag, I get with the validator one error,
while with only invalid attributes I get many errors with the validator :D
Fourth: it works! . I've tested this with every well known browsers: opera 9, firefox, IE5,I6, IE7 (beta),
a clone of safari for windows (swift (http://www.getswift.org/)) .
There's only one browser that resist : konqueror, it doesn't add the tag to the dom tree. But anyway, konqueror is not widely used.
So tell me: do you have any good reason to resist to the use of an invalid markup ? I've been looking to all famous javascript libraries (moo fx, scriptaculous, dojo toolkit), YUI, all seem to avoid the use of invalid markup.
However the use of invalid attributes seems tolerated. . At least according to "dojo toolkit (http://dojotoolkit.org/)" use. So why not a little step further, invalid markup ?
Also I tryed to make a "minimalistic DTD", that will be added to the standard one, in other to validate my newly introduced tag. But I wasn't able to do that: too complicated. I do not want a DTD that has a too big size (4 kb maximum) . It seems that XHTML specifications are too heavy, and that the langage is not really extensible for common uses.
Anyway, I'm not sure that after doing the trick that konqueror will accept my tag.
Any suggestions ? Thanks.
I've been browsing the web for hours,
and wasn't able to answer to this question: what's wrong with using "non standard markups" (other would say invalid) for scripting purposes ?
I like the idea of storing dedicated attributes in a dedicated tag.
I've made a kind of popup script (not exactely a popup, but a lightbox-like (http://www.huddletogether.com/projects/lightbox/))
and here's how basically how it works.
Let's call the tag "darkbox"
So basically the code would be like:
<a href="link.htm">
<darkbox bottom="blue" title="my title" width="500" effect="zx" type="iframe" >
</darkbox>
</a>
I will initialize the page with an external js script , that will loop through all
the "darbox" tags.
It is pretty straightforward, I just have to do : document.getElementsByTagName("darkbox")
and then retrieve all these particular attributes using getAttribute.
After that , I can assign an onClick event to the parent tag which is a link .
Before you make an objection, you might ask why not put all attributes directely in the "a" link tag ?
First: I find the code easier to read
I keep attributes specific to the popup effect separate to "a" link tag.
Second: I don't want to conflict with existing valid attributes.
Special attributes stay dedicated to the popup effect.
Third: You may suggest the use of a class called "darkbox", and make a loop that check all span tags that have a class called "darkbox".
I would say then: the problem of non valid attributes remain.
Even if I put them in the "a" tag, the w3 validator (http://validator.w3.org/) will show errors.
Worst: with an invalid tag, I get with the validator one error,
while with only invalid attributes I get many errors with the validator :D
Fourth: it works! . I've tested this with every well known browsers: opera 9, firefox, IE5,I6, IE7 (beta),
a clone of safari for windows (swift (http://www.getswift.org/)) .
There's only one browser that resist : konqueror, it doesn't add the tag to the dom tree. But anyway, konqueror is not widely used.
So tell me: do you have any good reason to resist to the use of an invalid markup ? I've been looking to all famous javascript libraries (moo fx, scriptaculous, dojo toolkit), YUI, all seem to avoid the use of invalid markup.
However the use of invalid attributes seems tolerated. . At least according to "dojo toolkit (http://dojotoolkit.org/)" use. So why not a little step further, invalid markup ?
Also I tryed to make a "minimalistic DTD", that will be added to the standard one, in other to validate my newly introduced tag. But I wasn't able to do that: too complicated. I do not want a DTD that has a too big size (4 kb maximum) . It seems that XHTML specifications are too heavy, and that the langage is not really extensible for common uses.
Anyway, I'm not sure that after doing the trick that konqueror will accept my tag.
Any suggestions ? Thanks.