SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript for drop-downs in Transitional menu?

    As part of a website redesign, I've converted all my pages' doctypes from HTML Trans to XHTML Trans. My original pages had a horizontal top menu bar with drop-down menus on most of the links. That menu was exported from Fireworks MX 04 into Dreamweaver MX 04. It looks great and works fine, but it uses tons of javascript and isn't particularly easy to update.

    So I would like to replace it with a CSS-based horizontal menu bar with drop-downs, and I've found multiple prototypes both online and in books. The trouble is that none of these source navbars validate to the XHTML Transitional doctype, because of a recurring text in the javascript: document.getElementById.

    A Real Validator singles out that text with every navbar I've tried (there were many), calling it an "unknown entity," and refuses to validate my otherwise-compliant pages. I do not know how to write javascript, so I've run out of options and at this point might have to stick with my exported FW menu bar.

    Can anyone direct me to code for a CSS horizontal navbar with dropdowns and an XHTML Trans-compatible javascript? Or just to a generic javascript which would work with any such navbar? Or is there no such thing?

    Thanks for reading,

    Annie

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Annie,

    It serems extremely strange that a validator would raise an error with that particular Javascript statement. It gives me the impression that problem lies elsewhere.

    Could you please provide some code for us to take a look at, or a link to a site? I have never known any Javascript itself to cause the XHTML validation to fail. Maybe the implementation of the "script" tags or how the functions are called; but not the code itself.

    Regards,
    Jordan

  3. #3
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XHTML requires JavaScript scripts to be contained within CDATA elements. Usually, the easiest way to handle the problem is to put the scripts in an external .js file. It is often preferable to apply event listeners to elements through window.onload, as well. I believe transitional XHTML still allows onevent attributes to tags, but I don't think the stricter forms do. I could be mistaken, though, as it's been a while since I studied it. It is this sort of thing that has caused a consortium of interests, with the W3C's blessing, to undertake the definition of an HTML 5 standard.

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    JVLB was right on the money. When I added the CDATA elements, the validation came through.

    Thanks for the helpful replies, I am so relieved!

    Annie


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
  •