trouble validating in XHTML

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
alabuc
Super Advanced
Super Advanced
Posts: 30
Joined: Mon Dec 22, 2003 12:22 am
Location: NY
Contact:

trouble validating in XHTML

Post by alabuc »

i've previously had some issues validating with the menu in HTML but thanks to you guys i got those all straightened out... now for XHTML 1.0 Strict. :( im not really sure what the problem is but here's the site i'm working on.

http://www.alabu.com/ibc/

and the validation link:

http://validator.w3.org/check?uri=http% ... ly%29&ss=1

if anyone knows how to fix those two errors (it was originally 10 but it messed with it until i got it down to 2) i would very much appreciate it. Thanks!

~Hal
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Haven't tried strict yet, but this looks wrong anyway. You have...

Code: Select all

<script src="java/milonic_src.js" type="text/javascript"></script>
<script type="text/javascript">
if(ns4)_d.write("<script type='text/javascript' src='java/mmenuns4.js'>");
else _d.write("<script type='text/javascript' src='java/mmenudom.js'>");
</script>
</script>
</script>
<script src="java/menu_data.js" type="text/javascript"></script>
You can't have 3 </script> in a row like that. It implies nested scripts, which I'm pretty sure is a no-no. Besides, there are too many. With your code it should look like this...

Code: Select all

<script language="javascript" src="java/milonic_src.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
if(ns4)_d.write("<script type='text/javascript' src='java/mmenuns4.js'>");
else _d.write("<script type='text/javascript' src='java/mmenudom.js'>");
</script>
<script language="javascript" src="java/menu_data.js" type="text/javascript"></script>
You also left out the language="javascript", which I put back in. I'm not sure about the changes you made to the ns4 and dom rows. That may be for strict.

Andy's code is...

Code: Select all

<script language="javascript" src="/menu5/milonic_src.js" type="text/javascript"></script>
<script language="javascript">
<!--
if(ns4)_d.write("<scr"+"ipt language=javascript src=/menu5/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=javascript src=/menu5/mmenudom.js><\/scr"+"ipt>");
-->
</script>
<script language="javascript" src="/menu5/menu_data.js" type="text/javascript"></script>
I got around a transitional error cleanly by using the <!-- --> stuff.

HTH...
John
alabuc
Super Advanced
Super Advanced
Posts: 30
Joined: Mon Dec 22, 2003 12:22 am
Location: NY
Contact:

Post by alabuc »

Thank you!! looks like the <!-- --> is what fixed it... as far as taking language out. the XHTML 1.0 strict validator told me its not a valid attribute, and also that type is a required attribute(:D dont ask me i dont keep up with these rules)... and same thing with the three </script> in a row, the validator told me i had omitted them so i kept adding them until it stopped complaining (i think it got jacked up from the IF test and stuff) anyways, this is the code that validated for me:

Code: Select all

<script src="/ibc/java/milonic_src.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
if(ns4)_d.write("<scr"+"ipt type=\"text\/javascript\" src=\"\/ibc\/java\/mmenuns4.js\"><\/scr"+"ipt>");
else _d.write("<scr"+"ipt type=\"text\/javascript\" src=\"\/ibc\/java\/mmenudom.js\"><\/scr"+"ipt>");
-->
</script>
<script src="/ibc/java/menu_data.js" type="text/javascript"></script>
EDIT: For anyone else with this issue... make sure you enclose your attributes with \"attribute\" because quotes are required in XHTML 1.0 strict. The \ before the quote is an escape character which allows it to print an actual quotation mark instead of ending the current quotation(because its already inside quotation marks). same thing goes for /'s you have to escape them as \/ in order for it to read it properly...mmm hope thats not too confusing
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Glad that worked (but I'm not going to go back and re-val as strict the 300+ pages I'm working on right now !). :roll:
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Interesting, although I don't get any errors using CDATA around js.
//<![CDATA[

//]]>

maz
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

As mentioned, CDATA is only needed if there are certain special characters contained in the JS (posted a list someplace here). Also, I've heard stories about IE having fits with CDATA, which I have seen here. Never have been able to get a CDATA page to validate, either.
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

John,

CDATA always validates it even says to use it to hide code.

I was experimenting with that above and got different errors in different browsers.

maz
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Don't know what to tell you, Maz. Any time I try validating with it in there the W3C validator (which obviously has nothing to do with any browser) always throws a fit.
John
Post Reply