Page Validation

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
rww
Advanced
Advanced
Posts: 11
Joined: Sat Mar 13, 2004 4:34 pm

Page Validation

Post by rww »

The way that Milonic uses:

<script language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");
</script>

keeps pages from validating as XHTML 1.0 Transitional. I've run my pages through http://validator.w3.org/ and the errors I get are:

document type does not allow element "script" here
...itedesign/common/scripts/mmenuns4.js'><\/script>");

and,

character "<" is the first character of a delimiter but occurred as data
...tedesign/common/scripts/mmenuns4.js'><\/script>");

Is there any way to fix this?
Thanks
RWW
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Yes, there's something about cdata being used. I have no idea what that is but I've read a few places on the forum where it had to be used to hide the script for whatever reason. Find Maz's name in a forum post then click her www button and check her website. Look at the source, you'll see how she uses it.

Ruth
Swetsenegger
Super Advanced
Super Advanced
Posts: 32
Joined: Sun Jun 13, 2004 11:05 pm
Location: Rotterdam, The Netherlands
Contact:

Post by Swetsenegger »

<script type="text/javascript">
<!--
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");
-->
</script>

Just add the 'comment' tags.
My site is XHTML 1.1 strict validated with this code.

Ow and remove <script language=JavaScript> and change it to <script type="text/javascript">. Don't forget to add the quotes for every value in XHTML.
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Hi,

You need CDATA tags, I added an example in the beginners section of the forum for getting started.

maz
tepidarium
Mega User
Mega User
Posts: 169
Joined: Sun Oct 05, 2003 4:21 am

Post by tepidarium »

Maz wrote:Hi,

You need CDATA tags, I added an example in the beginners section of the forum for getting started.

maz
I did a search for xhtml validation and found this thread. Looks interesting...so it only has to be placed around the javascript statemnt that refers to NN4?
BTW -what is CDATA?
hatchywatchy
Beginner
Beginner
Posts: 1
Joined: Tue Apr 29, 2008 4:15 pm

Re: Page Validation

Post by hatchywatchy »

Hi all,

It would require the code to look as follows:

Code: Select all

<script type="text/javascript"><!--//--><![CDATA[//><!--

if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>"); 

//--><!]]></script>
Let me know if it passes Validation.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: Page Validation

Post by John »

Actually the calls were changed a long time ago (it's in the download file!)...

Code: Select all

<script type="text/javascript" src="milonic_src.js"></script>
<noscript><a href="https://milonic.com/">JavaScript DHTML Menu Powered by Milonic</a></noscript>
<script type="text/javascript" src="mmenudom.js"></script>
<script type="text/javascript" src="menu_data.js"></script>
John
Post Reply