PDA

View Full Version : javascript general questions



leonidassavvides
05-17-2008, 09:22 AM
js q
The

<script type="text/javascript">
//<![CDATA[
.... javascript code
//]]>
</script>
or //<!--, and //-->
are equivalent ?

When I use fieldset in an html form may
1) may include image as title ?
2) may choose color and size of border of fieldset enclosed ?
3) may choose a background for the fieldset content area ?

jscheuer1
05-17-2008, 05:25 PM
They're similar, but each is designed to 'hide' the javascript from different processes. The CDATA comment (if properly formed, I'd have to Google that to be sure) is to hide it from xml processing (which if your page isn't doing, and can't do via its DTD and opening tags, you don't need to worry about), and the HTML style comment (which is actually <!--, and // -->) is to hide it from older browsers (very old browsers, at this point) that don't know enough to ignore what's inside a script tag, even though they don't support javascript. The two may be combined somehow, but again I'd have to Google that for the exact syntax.

The rest of your questions I'm not 100% sure on, but I'm 100% sure that some of these vary by browser, degrading reasonably well where not supported. My best advice to you on them is to try them. But you should also consult the w3c standard to see if they are technically allowed. If they are not, they will probably cause problems in some cases, in some browsers. The easiest way to test conformance of your HTML markup is with the validator:

http://validator.w3.org/