DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #13 - dhtmlab.com
Frequently Asked Question #13
Entered: August 22, 2000
|I am using IE5 Macintosh. The examples on DHTML Lab work fine, but I am having a problem with my own implementations. The menus work fine on some pages, but not on others. All of my pages use the same hierArrays.js and hierMenus.js files. The in-page parameters are identical and no other possibly-conflicting scripts are being used. Why am I getting these seemingly random problems?|
IE5 for the Macintosh has been universally acclaimed as the most standards-compliant browser released from the "big two" vendors. For example, see WebReview's CSS support table. Its support of the HTML 4 standard is also the most W3C-compliant.
In many cases, its support may be "too" good.
Many authors are now using the DOCTYPE tag at the beginning of their documents to define the Document Type Declaration (DTD) that the document adheres to. If you are unfamiliar with DOCTYPE and DTD's, there is a useful overview on HTML with Style that will bring you up-to-date quickly.
Here is an example DOCTYPE tag:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Many third-party HTML editors add DOCTYPE to the beginning of documents automatically. Authors rarely exclude it from pages where it has been inserted automatically, because more often than not they regard DOCTYPE as "harmless overhead." Until the release of IE5 Macintosh, DOCTYPE was truly a "vanity tag," like many of the META tags identifying page-creation software, since no browser from Microsoft or Netscape parsed it in any useful manner.
IE5 Macintosh reads DOCTYPE and if a DTD URL is specified, loads the DTD and compares your document's syntax against it. If your document does not comply completely with the DTD, a syntax error may be generated.
The HM script is very loosely written. In many cases, pixel unit identifiers are missing from scripted style assignments. For example, the itemPad parameter defines item element padding. When we initially declare it, we give it an integer value:
itemPad = 3;
Later, in the script we assign it to the padding property of an item element's style:
itemElement.style.padding = itemPad;
The syntax expected by the DTD, however, is:
itemElement.style.padding = itemPad + "px";
IE, following its own internal logic, will assume an integer to be a pixel value. This is valid IE syntax. However, an external DTD overrules the internal logic. If the syntax does not conform in a scripting setting, an error may be generated.
Go through the HM script, changing all integer assignments to string pixel assignments.
Omit the URL part of the DOCTYPE tag, on pages that use the HM script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
You, as an author, know if your document complies with the standard. If not, run it through a validator. By omitting the URL, your page will load faster, as the DTD will not be loaded from the W3C web site.
Now that browsers are using the DOCTYPE tag, we will "stick to the rules" in our script. HM, Version 4 will assume that the DOCTYPE tag DTD URL exists, and script accordingly.
Many thanks to Mike Chaney, for being the first to include a DTD URL in an HM page, and consequently exposing this problem.
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.
Created: Aug 22, 2000
Revised: June 26, 2001