SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Works in IE,NS4, NOT MOZILLA?

    This works in IE and NS4 but in Mozilla (Firebird) it displays part of the javascript as page content instead of scripting. It's a very old 'mouseover generator' that writes javascript that had so many requests when I removed it I had to put it back in.

    Obviously this browser represents a miniscule segment of site visitors but I use it myself and therefore care

    http://www.websitegoodies.com/article.php?id=2

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh goody, I'm gonna have fun trying to explain this

    Bear with me, I'll get there eventually.

    First, the head-exploding bit: There's no such thing as an HTML comment.

    This:
    Code:
    <!-- I'm a comment, right? -->
    is actually more complicated than it first appears.

    The "<!" and ">" delimiters indicate that their contents are Standard Generalised Markup Language - SGML. As its name suggests, SGML is a more generalised markup language, of which HTML, XML, and others, are merely applications.

    See that doctype?
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
       "http://www.w3.org/TR/html4/loose.dtd">
    That's SGML, that is.

    Now, go look at that comment again. See the "<!" at the start, and the ">" at the end? The stuff inside is SGML. In SGML, comments are delimited by a double hyphen: "--". One double hyphen to start, another to end.

    Now, in your page, you have javascript inside a comment. In that javascript, you're writing more comments. Moz's parser is probably getting rather confused by all this. The fact that your javascript also has HTML embedded in it, including <script></script> tags, probably isn't helping much, either.

    Mozilla is seeing your javascript like this:
    Code:
    <!-- [SGML comment, ignore it]
     -- [we're out of the SGML comment, but all I can see is a bunch of javascript]
     -- [now we're back in another SGML comment]
     -- [javascript, more javascript, Oooo! a ">" followed by a "</script>", that 
    must be the end.  Right, back to the HTML parser]
    Unfortunately, at that point, it's still in the middle of your Javascript...

    I notice you've split the comments being written, so that the delimiters are like this:
    Code:
    '... <'+'!-- ...'
    You could probably improve things by breaking up the double hyphen, too:
    Code:
    '... <'+'!-'+'- ...'
    If (when) more browsers start to do a better job of parsing the SGML in documents (which may well be necessary to deal with the more advanced XML-based stuff that might happen in the future) more browsers are going to run into this stuff.

    Note: yes, this can happen with the Decrement Operator ("i--;") too.

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply Gav, I'll try to clean it up til Mozilla stops throwing it into the HTML, now that I have some idea of what it's thinking

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Perfect! Thanks again. I broke up the --></script> several times before where Mozilla was starting to put the stuff into the page content and now it displays AND executes perfectly

  5. #5
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. Glad to help...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •