Anyone else noticed this issue?

Discussion in 'HTML' started by Justin E. Miller, Mar 7, 2008.

  1. In XHTML 1.0 Strict, the correct declaration for calling an external
    JavaScript is <script type="text/javascript" src="script2.13.js" />
    right? Running the validator on my page, I got it being correct as
    either the preceding or <script type="text/javascript"
    src="script2.13.js"></script>. I would figure one would want to use the
    former considering it uses less bytes of data, though largely irrelevant
    on most connections.

    I'm using Firefox 3.0 B3 and have noticed that the page is blank,
    despite it passing validation by the W3 validator. The same page works
    in Opera and Firefox 2.0.0.12 though. Not unsurprisingly, it doesn't
    work in IE 6. I'm running Linux, so I can't run IE7 currently to test it
    in there. It seems to be a bug with the programs not handling the
    XHTML+XML declaration, so I submitted a bug report to Mozilla. I just
    wanted to see if it was just my computer screwing things up.

    I'm learning JavaScript through a book that is using XHTML 1.0
    Transitional and these are just scripts from that book. I changed the
    code to be Strict because I prefer to use it.

    They are online at:
    http://www.justinandlindseymiller.com/javascript_work/index.html

    I don't need any feedback on it other than whether or not it works in
    the browser you're using.

    Thanks for your time.
     
    Justin E. Miller, Mar 7, 2008
    #1
    1. Advertisements

  2. Scripsit Justin E. Miller:
    What makes you think so, and specifically that it is _the_ correct
    declaration? Which part of the XHTML 1.0 specification made you draw
    that conclusion.
    Does that surprise you? Why?

    The following is valid, too, though not correct:

    <script type="I made this up!" src="And this too!">Nothing to be seen
    Why are you using XHTML in the first place?

    The "self-closing tag" idea, often advertized as fundamental to XHTML,
    is generally misunderstood and it wasn't a great idea from the
    beginning. An element with EMPTY declared content is generally something
    tricky and a symptom of retrofitting a simple quick-and-dirty tagging
    system into the formal framework of "generalized markup" (first SGML,
    later XML); see
    http://www.cs.tut.fi/~jkorpela/html/empty.html

    On the technical side, both XML and XHML specifications say clearly that
    "for compatibility", the self-closing tag construct should be used for
    elements with EMPTY declared content (i.e., for elements that can never
    have any content, by the syntax rules), and for them only. So although
    <div /> is valid, it should not be used; ditto for <script ... />.

    In practice, legacy browsers (especially when in text/html parsing mode)
    may well ignore the slash and treat <script ... /> as <script ... >, and
    there goes the rest of the document. By HTML _specifications_ up to and
    including HTML 4.01, the slash has a special meaning, but completely
    different from XHTML rules.
    HTML is best learned from books on HTML. There are many books on HTML.
    Unfortunately, most of them are between sloppy and miserable, and the
    best one (coauthored by me) is available in Finnish only; sorry. But I'm
    sure some of the HTML books often mentioned in this group are good.
    That's the shrewd way of getting feedback on Usenet. :)

    The very first script is this:

    document.write("Hello, World!");

    It seems that you need a new JavaScript book, too, since such operations
    are _so_ outdated. You often see document.write() in legacy code, but
    it's _not_ the modern way, especially if playing with XHTML. You're
    supposed to manipulate the document tree, using a W3C-approved Document
    Object Model, instead of throwing in strings to be parsed as (X)HTML at
    runtime.
     
    Jukka K. Korpela, Mar 7, 2008
    #2
    1. Advertisements

  3. Technically, yes. But the behaviour of may current browsers is to
    interpret XHTML pages as if they were plain old HTML unless they are
    served with an XHTML or XML Content-Type header. Thus your <script>
    element may be parsed according to HTML rules, and interpreted as if it
    were:

    <script type="text/javascript" src="script2.13.js">

    That is, no closing tag -- so the remainder of the page is seen as being
    *part* of the script!
    http://www.tatanka.com.br/ies4linux/page/Beta

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 37 days, 17:22.]
    [Now Playing: Ray Charles - Funny but I Still Love You]

    Bottled Water
    http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
     
    Toby A Inkster, Mar 7, 2008
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.