Forum Moderators: open

Message Too Old, No Replies

comment? bug in Mozilla

Is this normal in Mozilla

         

jeremy

10:46 am on Apr 29, 2003 (gmt 0)

10+ Year Member



When I changed my file type to xhtml, several thing happened.
1. The font size problems I was having all disappeared. That was the good part, now the interesting part
2. I had some comments that I use as dividers to separate my code. The comments were just like
<!-- Whatever ------------------------------------ -->
This does not cause any problems EXCEPT in Mozilla which displays the whole line on screen. I guess Mozilla does not parse it correctly because it expects the closing > after a couple of --, so it does not recognise it as a comment.

The problem goes away when I change the -- to any other character.

Nick_W

10:55 am on Apr 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmmmm.... not sure. I rarely use comments in html (bad Nick_W!, bad!)...

anyone have the take on this?

PS: Moved post to browsers ;)

Nick

WibbleWobble

12:27 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



I've never seen such a thing, and the example above parses correctly in Firebird, which is essentially Moz.

Receptional Andy

1:09 pm on Apr 29, 2003 (gmt 0)



I tried that in Moz with an xhtml file and it didn't display the comment. Are you sure it isn't something else causing the problem?

Nick_W

1:16 pm on Apr 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What kind of file extention are you giving this doc?

Nick

ytswy

1:17 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



I had a similar problem with Mozilla and comments containing --

If you try putting the page through the W3C validator I think you'll get an "invalid comment syntax" error, so its Mozilla being fussy as opposed to buggy.

Drove me mad untill I posted it here and Papabaer sorted me out.. Only solution I found was not to put -- in comments...

<added>I was using a 4.01 Transitional Doctype</added>

g1smd

11:48 pm on Apr 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Valid comments look like:

blah blah <!-- comment --> blah blah

Are you sure that you had the syntax correct; exactly TWO dashes, and at least one space on both sides of both of the tags?

What does the validator say?

jeremy

12:02 am on Apr 30, 2003 (gmt 0)

10+ Year Member



The comment was writen exactly as I wrote in the original post.
The validator says something like multiple comments, I cannot remember exactly the phrase it used.
To me <!-- fdhsk ------------- --> is a valid comment. IT opens with <!-- and closes with -->.

I just chose to use the - as a means of elongating the comment to cover a line for my own benefit.

jeremy

12:03 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



For anyone still reading this post.
I tried to validate a couple more files and this was the result in another

Line 15, column 58: S separator in comment declaration
mail_str += "&body= I thought this would interest you -- " + document.title;
^

Line 15, column 59: invalid comment declaration
mail_str += "&body= I thought this would interest you -- " + document.title;

The parser appears not like -- anywhere, even inside strings!

grahamstewart

12:23 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ah.. looks like your using comments to 'hide' javascript from the browser inside an xhtml document. This is a no-no.

Use external javascript instead.

jeremy

12:42 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



Hello Graham,
I do not think that was the case. The actual line the validator picked up was the following

function mailPage() {
var mail_str = "mailto:?subject= " + document.title;
mail_str += "&body= I thought this would interest you -- " + document.title;
mail_str += ". You should check this out at, " + location.href;
location.href = mail_str;
return true;
}

I generally develop pages with some javascript in them and when finished I move the js to an external file.

I Just think the parser has trouble with hyphens --, especially two of them, even when contained in a string. It automatically assumes they are part of a comment.

PS. This site is a great help to me.

pageoneresults

12:50 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure if this applies, but if you have a string of hyphens within your comment tag it will produce errors.

From the W3C...

White space is not permitted between the markup declaration open delimiter("<!") and the comment open delimiter ("--"), but is permitted between the comment close delimiter ("--") and the markup declaration close delimiter (">"). A common error is to include a string of hyphens ("---") within a comment. Authors should avoid putting two or more adjacent hyphens inside comments.

3.2.4 Comments [w3.org]

grahamstewart

1:08 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nah.. its definitely a no-no unless you put a cdata block around it (which some browsers don't like).

See...
[webmasterworld.com...]
[webmasterworld.com...]

BjarneDM

2:28 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



take a look here:
[xml.com...]
for some real hard-core information on html, xhtml, doctypes, javascript, and browser support.

reeeallly interesting reading.

I can personally attest to the fact, that xhtml served as application/xhtml+xml is interpreted *very* strictly in Mozilla and is a superb way of testing for valid markup - especially on dynamically generated php & mysql xhtml pages.