HierMenus CENTRAL: HierMenus In Progress. HM5 Status Report: Adding Opera (2/5) | WebReference

HierMenus CENTRAL: HierMenus In Progress. HM5 Status Report: Adding Opera (2/5)

To page 1current pageTo page 3To page 4To page 5
[previous] [next]

Welcome Opera 7

In the past, we've hesitated about adding Opera support to HM due to its lack of post-page-load document element and page creation and manipulation capabilities. Opera has long supported basic DHTML needs--such as the ability to hide, move, and redisplay positioned page elements--and with each new release its DHTML support has been improved. However, the full ability to create and insert new document elements after a page has been loaded--the exact technique needed within our HM architecture--has not been fully developed.

Until now, that is. With their latest release, we can now support the creation of HierMenus in Opera, and we've set out to make the necessary adjustments to HM to accommodate this new browser.

Standards vs. Quirks

Like Internet Explorer, Opera 7 is delivered with support for two separate rendering algorithms: Standards Mode and Quirks Mode. Standards mode, as you would guess, offers support for the DOM and HTML specifications; displaying pages as they should be displayed based on the actual specifications themselves. Quirks Mode, on the other hand, is included to support older pages that were built assuming certain non-standard browser behaviors, and therefore emulates the display of pages as they would have been if viewed by one of these older browsers. Specifically, Opera describes their Quirks Mode behavior as "...essentially an Internet Explorer compatible mode," meaning that it renders pages using the same rules as IE6 would when its own "Quirks Mode" is enabled. Also like IE6, Opera uses the DOCTYPE of the page (or lack thereof) to determine whether to enter Standards mode or Quirks mode. In fact, Opera uses the same methodology for determing which mode to enter as IE does; meaning that a specific DOCTYPE declaration will trigger Quirks mode in both browsers.

This is great news for HM. As regular readers will recall, we've already added support to HM for differences between the two rendering modes in Internet Explorer. As a result, we should be able to piggy-back Opera Quirks mode behavior onto our existing IE quirks mode behavior. This is indeed the case, and to our delight we found that the majority of changes necessary to support Opera simply required identifying Opera as running in Quirks mode, and then applying the same conditional logic to Opera Quirks mode as we do for IE quirks; or specifically, when the HM_IEnoDTD variable is true.

For Opera in Standards mode, the changes were even easier. To accommodate Opera's Standards mode, we've needed to do little more than simply identify the browser as HM compliant (making sure it's Opera v6 or later) and then let it through to the main HM_ScriptDOM.js. Hallelujah! A great victory for standards compliance, and kudos to the Opera team for their hard work.

Identifying Opera as being run in Quirks Mode vs. Standards Mode is relatively easy; as Opera utilizes the document.compatMode property to allow developers to know which rendering algorithm is in effect. We first utilized and documented this property back in HM version 4.1.2. Like IE6, standards mode is identified as CSS1Compat. Unlike IE6, Opera reports QuirksMode for this property when in quirks mode, instead of BackCompat. Therefore, sniffing Opera's Quirks rendering mode is as follows:

HM_OperaQuirk = (HM_Opera && 
         (document.compatMode != "CSS1Compat"));

The HM_Opera variable is based on typical sniffing of the browser and version from the browser's User Agent. From here, adding Opera support was as simple as adding checks for the HM_OperaQuirk boolean at the same places we check for HM_IEnoDTD.

For the most part, that is. We did run into a couple minor issues with the implementation. Let's take a look at those issues now.

To page 1current pageTo page 3To page 4To page 5
[previous] [next]

Created: March 12, 2003
Revised: March 12, 2003

URL: https://www.webreference.com/dhtml/hiermenus/inprogress/1/2.html

Justtechjobs.comFind a programming school near you






Online Campus Both