SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast jester_original's Avatar
    Join Date
    Aug 2004
    Location
    devon
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript error in xhtml validator

    Hi all,
    Hope someone can help, i'm trying to validate my site in xhtml, the only page throwing an error is the index page javascript, it is part of the 'suckerfish drop down menu' i have used, it is as follows:

    <script language="javascript" type="text/javascript">
    startList = function() {
    if (document.all&&document.getElementById) {
    navRoot = document.getElementById("nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
    node.onmouseover=function() {
    this.className+=" over";
    }
    node.onmouseout=function() {
    this.className=this.className.replace(" over", "");
    }
    }
    }
    }
    }
    window.onload=startList;

    function changeSrc(page){
    document.getElementById("content").src= page
    }
    </script>

    the error i get is:
    character "&" is the first character of a delimiter but occurred as data

    if (document.all&&document.getElementById) {


    i have replaced the && with the &amp; code which validates ok, but stops the nav from working.
    Any help would be greatly appreciated

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have the wrong forum. Either the javascript one or one of the design your site ones.

  3. #3
    SitePoint Enthusiast jester_original's Avatar
    Join Date
    Aug 2004
    Location
    devon
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops
    ta

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You need to use CDATA comments: http://www.codehouse.com/javascript/tips/xhtml/

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

    alert("<This is compatible with XHTML>");

    //]]>
    </script>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •