Jump to content

criley

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by criley

  1. I got this reply from a member of the W3C working group about some "unfortunate rules about XML". Interesting:

    The validator's error is expected. In XHTML, the "script" element uses adifferent content model than in HTML [1]. The result is that the XMLcomment surrounding your JavaScript is actually a real XML comment, whichhas unfortunate rules about "--" within the comment [2].You can make the error go away by replacing "i--" with "i -= 1" or byremoving the XML comment tokens from your "script". Note that the XML comment would cause your JavaScript to be ignored by an XHTML browser, but this generally doesn't happen in practice because most browsers treat XHTML as HTML.For a more complete discussion, see <http://lachy.id.au/log/2005/05/script-comments>.[1] http://www.w3.org/TR/xhtml1/#h-4.8[2] http://www.w3.org/TR/REC-xml/#sec-comments
    Chris
    The best thing I can suggest is to simply call your JS code from another file like you should anyway.
    Yup, but I was curious.
  2. Try telling the parser that there is character data to follow like so.<script><![CDATA[put all javascript here ...function matchwo()]]></script>
    Thanx Scott. Unfortunately the validator just passes over the declaration and continues to show the same error.C
  3. Hi all,First time poster, long time human.I have an inline line of JavaScript that fails the W3C validator for XHTML 1.0 Strict. (http://validator.w3.org/detailed.html)Here's the code:

    	for(i=selectbox.options.length-1;i>=0;i--)	{		...code;...	}

    At the end of the for statement, the validator seems to see the two dashes and right parenthesis as a mal-formed HTML comment delimiter. I.e. "--)". Anyone know how to prevent this error, or why it even shows up in a JavaSript statement? Frankly, I didn't think the validator would even look at the JavaScript because of the SCRIPT delimiter. I thought it would see this and just ignore it since that's not where HTML would ever be placed (unless embedded into the script with print statements).My JavaScript delimiter:<script type="text/javascript"><!--- ...code...//---></script>My DTD statement:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca" lang="en-ca">Any ideas?Thanx.

×
×
  • Create New...