Hello,
aq****@gmail.com wrote:
I have a page with a javascript date calculation in it, and the W3C
validator tells me that the statement
--tdiff;
is invalid.
>>>>>>>
Error Line 38 column 3: invalid comment declaration: found name start
character outside comment but inside comment declaration.
--tdiff;
<<<<<
Aside from writing tdiff = tdiff -1; how should I code this?
See www.rurale.ca or specifically
www.plonque.com/rurale/bowl2006.php
Generally: don't use comments in SCRIPT elements (same for STYLE) like
<script ..><!-- .. --></script>
This is for user-agents that do not know the special semantics of SCRIPT and
STYLE. These elements are around for quite a while, so I doupt there's any
user-agent left in the wild, which requires these comments.
And you are using XHTML which makes these comments even more lethal: in
XHTML these comments *are* real comments (in HTML only those deprecated
user-agents would parse it as comments). So if the document is parsed as
XML (parsing XHTML as HTML is just a temporary work-around) as XHTML is
supposed to be and you fixed the parse error, the SCRIPT element would
contain nothing at all.
You have the following options:
- Stick with HTML. In this case you can savely omit the comments.
- If you have very good reasons to use XHTML, use <![CDATA[ .. ]]instead
of <!-- --(or nothing at all, if your script does not contain any '<'s
or '&'s).
- Move the script to an extenal file and use
<script type="text/javascript" src="path/to/script.js"></script>
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW:
http://pink.odahoda.de/