Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Internet Explorer 4 mouse events

January 19, 1999

Testing whether the mouse has passed off the menu window in Internet Explorer 4.
function testOut(topic) 
{ toElement=window.event.toElement;
  if (toElement)
   {
    if (toElement.id!="backdrop")
     { inside=eval(topic+".contains(toElement)");
       if (!inside) 
        { clearPop2=self.setTimeout("self.resizeTo(0,0);
		opener.focus()",1000); 
        }
	  }
	}
	else { clearPop2=self.setTimeout("self.resizeTo(0,0);
		opener.focus()",1000);
		 } 
}

The testOut() function exists for the sake of Internet Explorer 4. An important aspect of the pop-up menus is not only how they pop-up, but how they disappear. Towards this end there are a set of "rules" governing the un-popping of a menu, as it were:

  1. When the menu pops up, the user has 5 seconds to move the mouse pointer over the menu window; otherwise, the window will disappear.
  2. When the user moves the mouse pointer over the menu window, it will remain popped indefinitely, until ...
  3. When the user moves the mouse pointer off the menu window it will disappear after 1 second. If the user moves the mouse pointer back over the menu window before 1 second has elapsed the menu window will revert to rule #2.

Ultimately, then, the testOut() function serves to enact rule #3 within Internet Explorer. Why only Internet Explorer? The Internet Explorer event model is somewhat different from the Netscape event model. Namely, Internet Explorer sports a concept known as "bubbling". When an event, such as a MouseOut, occurs as an element, that element may or may not handle that event (meaning, execute some code when the event fires). Unless specifically stopped from bubbling, however, the event then triggers ("bubbles") at the next element in the object model hierarchy. So, for a hyperlink inside a table which is inside a DIV block, moving the mouse pointer off the hyperlink would trigger a MouseOut at the link element, then at the table element, and then at the DIV element.

Why does any of this matter? The entire menu which appears in the menu window resides within a layer, also known as a DIV block in Internet Explorer. We want to know when the mouse pointer leaves this layer. If we merely test for a MouseOut at this DIV block, however, the event will trigger anytime the user moves the mouse across elements within the menu -- because moving over an element means moving off another, thereby generating a MouseOut which bubbles up to the DIV block. Oy!

To test rule #3, then, we have concocted testOut(). This function checks just which element the mouse has passed onto, via the window.event.toElement property. If this destination element is not a child of the DIV block then we know the mouse has truly passed off the menu layer rather than off an element within the menu. Should this be true the 1 second timer is set to minimize and hide the menu window, effectively causing it to disappear according to rule #3.

A Cross Browser Dictionary
DHTML Pop-Up Menus: A Parable of Triumph and Loss (Based on a True Story)
Setting up the menu's layers


Up to => Home / Authoring / DHTML / Menus




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers