spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column20

Logo

Hierarchical Menus Ver. 2 (Cross-Browser/Frames)
navigating the menus

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

WebReference

Parameters used for the menus on this page:

menuWidth = 120;
childOverlap = 5;
childOffset = 5;
perCentOver = null;
secondsVisible = .5;

fntCol = "black";
fntSiz = 8;
fntBold = false;
fntItal = false;
fntFam = 
"MS Sans Serif"; backCol = "#9FB7C0"; overCol = "#507F90"; overFnt = "white"; borWid = 2; borCol = "#9FB7C0"; borSty = "outset"; itemPad = 2; imgSrc = "tri.gif"; imgSiz = 8; separator = 0; separatorCol = ""; isFrames = false;

Menu Animated GIF
Animated GIF demonstrating heirarchical menus for non-DHTML browsers.

In longer script listings, cross-browser code is blue, Navigator-specific code is red, and Explorer code is green.

Mousing Over the Menu

When the user mouses over any menu, the menuOver() function is called. It does not differ from its Version 1 incarnation. The relevant variables are updated and if the menu's hide timer has previously been set, it is cleared to avoid inadvertent hiding of the menu:

function menuOver() {
  this.isOn = true;
  isOverMenu = true;
  currentMenu = this;
  if (this.hideTimer) clearTimeout(this.hideTimer);
}

Mousing Out of the Menu

The menuOut() function has two changes from the previous version.

First, recall that in the Explorer event bubbling scenario, we have had to track the source of some mouse events to avoid background color "flicker." Review our discussion on the relevant page in column 15. Since the event may fire in either the window or a frame, we identify it using the menuLoc variable:

function menuOut() {
  if (IE4) {
    theEvent = menuLoc.event;
    if (theEvent.srcElement.contains(theEvent.toElement)) return;
  }
  this.isOn = false;
  isOverMenu = false;
  allTimer = setTimeout("currentMenu.hideTree()",10); 
}

The second change involves the final statement, which in version 1 was:

if (IE4) allTimer = setTimeout("currentMenu.hideTree()",10);

In our previous version, the menu element boundaries were identical to item boundaries, since the menu did not take up any additional screen space.

In Version 2, the menu provides the borders, so if a border is specified, the user's mouse physically moves over the menu element. Therefore, the menu events fire at a different time than the item events.

In Version 1, they fired at exactly the same pixel on the screen. This meant that, in Navigator's event hierarchy, the item event fired after the menu event. (see column 14) Thus, we allowed the item's mouseout handler to hide the menu.

In Version 2, when mousing out, the mouse first leaves the item, then the menu, so the menu hiding call now occurs in the menuOut() function for both browsers.

On the next page, we'll review the item mouse event functions.


Produced by Peter Belesis and


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger

All Rights Reserved. Legal Notices.
Created: May. 22, 1998
Revised: May. 22, 1998

URL: http://www.webreference.com/dhtml/column20/hier2Mover.html