By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

Javascript Arithmetic decrement --x; does not w3c-validate

P: n/a
Hi -
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

Thanx....
Tony King www.tonyking.tk

Nov 6 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 2006-11-06, aq****@gmail.com <aq****@gmail.comwrote:
Hi -
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?
tdiff -= 1;
Nov 6 '06 #2

P: n/a
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.
On its own, it isn't.
Error Line 38 column 3: invalid comment declaration: found name start
character outside comment but inside comment declaration.
--tdiff;
The only reason why that should occur is if you're using XHTML and
including comments (the markup variety) within the script element. Do
neither.
Aside from writing tdiff = tdiff -1; how should I code this?
Serving XHTML as text/html is pointless. See previous discussions in
this group for reasons.

The practice of "hiding" scripts is obsolete, doubly so in XHTML where
it literally means to ignore the script: to treat it as a comment.
See www.rurale.ca or specifically
www.plonque.com/rurale/bowl2006.php
As I suspected...

Mike
Nov 6 '06 #3

P: n/a

Ben C wrote:
On 2006-11-06, aq****@gmail.com <aq****@gmail.comwrote:
Hi -
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?

tdiff -= 1;
Geez! An answer WITHIN MINUTES! And it works!
Last time I posted on GG (a coupla years ago) it took 24 hours for it
to get posted, never mind the answer-time!
I've used =and <= but have nevr come across -= before.
Must brush up my javascript knowledge!

Thanx, Ben!

Nov 6 '06 #4

P: n/a
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/
Nov 6 '06 #5

P: n/a
On 2006-11-06, aq****@gmail.com <aq****@gmail.comwrote:
>
Ben C wrote:
>On 2006-11-06, aq****@gmail.com <aq****@gmail.comwrote:
Hi -
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?

tdiff -= 1;

Geez! An answer WITHIN MINUTES! And it works!
Last time I posted on GG (a coupla years ago) it took 24 hours for it
to get posted, never mind the answer-time!
I've used =and <= but have nevr come across -= before.
Must brush up my javascript knowledge!
Actually I replied a bit too quickly. As someone else pointed out, --tdiff is
legal EcmaScript anyway, so you may have had something else wrong.
Nov 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.