SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict drjones013's Avatar
    Join Date
    Jan 2007
    Location
    Las Vegas, NV
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Compatibility in XHTML

    I've spoken to several people about using XHTML and they feel (for formatting purposes) that it is superior to HTML in terms of forcing good structure. My company is running IE6 as the ONLY browser within their intranet and I've heard that in order to allow Javascript to run in XHTML an XML statement is required, theoretically something that IE does not allow. Is there a way to get IE and XHTML 1.0 Strict to get along or will I be forced to continue in 1.0 Transitional? I'm even having to consider rewriting the pages to HTML 4.01; other members within my staff feel that it would be more effective than chasing ghosts that may or may not exist.

    I haven't actually attempted anything yet-- we just finished the CSS and are working on content but the integration of Javascript is going to be pretty soon. If I'm totally wrong please let me know-- it would gladden my heart to know that I'm just being overly pessimistic.

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL! Sorry. IE doesn't support XHTML 1.0. It supports HTML 4.01, which is what XHTML 1.0 served as text/html is, except it has a few HTML errors, but HTML parsers are made to be rather fault tolerant.

    Like CSS, it's best to keep JavaScript in external files. That means no inline event handlers and empty script elements that use the src and type attributes.

    If your worried about how to make JavaScript work with XHTML when it's served with an XML mime-type, e.g. application/xhtml+xml (which IE doesn't properly support), then read these:
    Making JavaScript Compatible with XHTML
    Javascript and XHTML
    Properly Using CSS and JavaScript in XHTML Documents

    As to Transitional vs. Strict, Strict is better, especially if you aren't using lots of nested tables for layout.

    As to HTML 4.01 vs. XHTML 1.0, I still use HTML 4.01 most of the time. If you do choose XHTML, you should make sure that it always validates.
    However, I do write HTML that's closer to X(HT)ML (and recommend that others use the same if they choose to use HTML 4.01 as well):
    • Use lowercase element and attribute names in your HTML and CSS.
    • Use end tags even when they're optional.
    • Always quote values.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Addict drjones013's Avatar
    Join Date
    Jan 2007
    Location
    Las Vegas, NV
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That explains so much. My coworker hopped onto the forums trying to get a Javascript issue fixed here... I think the problem was the doctype then. So the only way to get Javascript to work is to switch to HTML 4.01? At least, in my circumstance?

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So the only way to get Javascript to work is to switch to HTML 4.01?
    *blink* That's not what I said.

    My coworker hopped onto the forums trying to get a Javascript issue fixed here... I think the problem was the doctype then.
    *shrugs* I'd have to read the thread in question to know whether is was or wasn't. And even then it might not provide enough information.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Addict drjones013's Avatar
    Join Date
    Jan 2007
    Location
    Las Vegas, NV
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I meant in my particular circumstance. Most of the articles show JavaScript written within the context of CDATA which I thought was the main problem with IE 6.0


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
  •