Results 1 to 4 of 4

Thread: w3c validation enigma--xhtml

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    286
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default w3c validation enigma--xhtml

    The w3c validation tool (http://validator.w3.org/) requires that various characters within xhtml be escaped. For example, "&"must be coded as "&amp;" and "<" must be coded as "&lt;". So far so good.

    My question relates to the situation where these characters are contained within a javascript script. I think it is clear that the escaped coding is NOT to be used within scripts. After all, w3c is not intended to validate script content. And the script processors do not know how to process escaped characters. Thus, in http://www.marainlaw.com/page.php?here=index, the validator disregards the ">" characters in its morning/afternoon/evening script. So far, so good.

    What is puzzling me is that on a different page that I am trying to develop, the validator is spitting out error messages concerning characters within a script that, were those not within a script, would have to be escaped. The errant page is http://www.marainlaw.com/page.php?here=test.

    What am I missing?

    A.
    Last edited by jscheuer1; 04-22-2012 at 04:16 PM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The solution is to either make the script external or to escape the entire script with not character data tags, example:

    Code:
    <script type="text/javascript">
    /* <![CDATA[ */
    
    /**********************************************************************************
    *
    * Left-Right Stripy Curtain Script- copyright Dynamic Drive (www.dynamicdrive.com)
    * Adapted from http://www.dynamicdrive.com/dynamicindex3/document3.htm
    * For full source code, 100s more free DHTML scripts, and TOS,
    * visit http://www.dynamicdrive.com
    *
    **********************************************************************************/
    
    var ns4=document.layers?1:0
    var ie4=document.all?1:0
    var ns6=document.getElementById&&!document.all?1:0
    
    var speed=20
    var temp=new Array()
    var  . . .
    
    
     . . . nterval(stopit)
    }
    }
    }
    function gogo(){
    stopit=setInterval("openit()",100)
    }
    gogo()
    /* ]]> */
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    286
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    John,

    Firstly, I appreciate your time in replying to my messages.

    That said, I remain puzzled why the validator appears to (correctly) ignore the unescaped ">"s in marainlaw.com/page.php?here=index.

    A.
    Last edited by jscheuer1; 04-22-2012 at 07:05 PM. Reason: Format

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I think they are escaped, just not correctly. The standard for XHTML is the not character data escape I just outlined for you. I believe that script uses the HTML comment escape:

    Code:
    <script type="text/javascript">
    <!--
    script code here
    // -->
    </script>
    Browsers are allowed to ignore that script completely, though few if any currently do.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    marain (04-28-2012)

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
  •