|
Posted by Harlan Messinger on January 29, 2008, 12:50 pm
Please log in for more thread options macruzq wrote:
> On Jan 28, 12:20 pm, Harlan Messinger
>> macruzq wrote:
>>> In a web page, there is a JS script. Comments start with // and I
>>> usually start any comment or remark in any language with -- ( two
>>> dashes).
>>> The case is when Amaya opens a .html file that has the following:
>>> . . . . . . . . . .
>>> <script type="text/javascript" language="JavaScript">
>>> <!-- ;
>>> function anyfunction(arg1,arg2,arg3)
>>> {
>>> //-- mask out, do not execute ;
>>> //-- alert("Image to set:"+button_image);
>>> document.getElementById(button_id).src=button_image;
>>> document.URL=url_dest;
>>> }
>>> //-->
>>> </script>
>>> . . . . . . . . . .
>>> Amaya reports parsing error:
>>> line nn, char n: not well-formed (invalid token)
>>> //-- mask out, do not execute ;
>>> [ ^ highlited]
>>> It shows same message even with "// --" (space after two slashes).
>>> Only with "// - - " (space after first dash) parsing error message
>>> stops from showing up.
>>> I think it should not give any message, because it is inside a
>>> comment. Should it?
>> It isn't inside the comment--it terminates the comment. See
>>
> Thank you for the hint.
>
>> http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4
>>
>> and, for more info,
>>
>> http://htmlhelp.com/reference/wilbur/misc/comment.html
>>
>> (though I discovered the IE6 and Firefox both fail to permit whitespace
>> between the final -- and the closing >. Actually, in that case, I'm
>> observing that even in the source code view in each browser, the entire
>> comments and everything that follows is missing. Does anyone know what
>> that is???)
>>
>> But unless you have specific reason to think you're still writing for
>> browsers that don't recognize the SCRIPT tag, there's no longer any
>> point to this exercise. The code
>>
>> > <script type="text/javascript" language="JavaScript">
>> > function anyfunction(arg1,arg2,arg3)
>> > {
>> > // mask out, do not execute ;
>> > // alert("Image to set:"+button_image);
>> > document.getElementById(button_id).src=button_image;
>> > document.URL=url_dest;
>> > }
>> > </script>
>>
>> is adequate.
>
> Of course it is adequate, but I have been doing this for several
> years. Thanks anyway.
I didn't mean you should get rid of the hyphens in front of your
Javascript comments, even though I did in my example. But why would you
keep wrapping the old script in an HTML comment when all it does is
limit your flexibility to format your Javascript as you want to?
|