home *** CD-ROM | disk | FTP | other *** search
- <HTML>
-
- <HEAD>
-
- <TITLE>Simulating Event Bubbling With Event Capturing</TITLE>
-
-
-
- <STYLE>
-
- #banner { font-family: arial, helvetica, sans-serif;
-
- font-size: 18pt; }
-
- </STYLE>
-
-
-
- <SCRIPT>
-
- eventText = "";
-
- capturingObject = "";
-
-
-
- function displayEvent(event)
-
- {
-
- eventText += capturingObject + " ---> ";
-
-
-
- if (event.target.constructor == Layer)
-
- resultLayer = document.layerResults;
-
- else
-
- resultLayer = document.linkResults;
-
-
-
- resultLayer.document.writeln("<P><TT>");
-
- resultLayer.document.writeln(eventText);
-
- resultLayer.document.writeln("</TT></P>");
-
- resultLayer.document.close();
-
- }
-
-
-
- function handleWindow(event)
-
- {
-
- // Initialize event
-
- cancelBubble = false;
-
- eventText = "";
-
-
-
- // Send event down event hierarchy
-
- var returnValue = routeEvent(event);
-
-
-
- // If bubble hasn't been cancelled,
-
- // execute window event handler code
-
- if (!cancelBubble)
-
- {
-
- capturingObject = "window";
-
- displayEvent(event);
-
- }
-
-
-
- // Return return value for default action
-
- return returnValue;
-
- }
-
-
-
- function handleDocument(event)
-
- {
-
- // Send event down event hierarchy
-
- var returnValue = routeEvent(event);
-
-
-
- // If bubble hasn't been cancelled,
-
- // execute window event handler code
-
- if (!cancelBubble)
-
- {
-
- capturingObject = "document";
-
- displayEvent(event);
-
- }
-
-
-
- // Return return value for default action
-
- return returnValue;
-
- }
-
-
-
- function handleLayer(event)
-
- {
-
- capturingObject = "layer";
-
- displayEvent(event);
-
- }
-
-
-
- function handleLink(event)
-
- {
-
- capturingObject = "link";
-
- displayEvent(event);
-
- cancelBubble = true;
-
- }
-
-
-
- function initialize()
-
- {
-
- window.captureEvents(Event.MOUSEOVER);
-
- window.onmouseover = handleWindow;
-
- document.captureEvents(Event.MOUSEOVER);
-
- document.onmouseover = handleDocument;
-
- }
-
- </SCRIPT>
-
-
-
- </HEAD>
-
-
-
-
-
- <BODY onLoad="initialize();">
-
-
-
- <LAYER ID=banner onMouseOver="handleLayer(event);">
-
- <A HREF="home.html" onMouseOver="handleLink(event);">
-
- <IMG SRC="arrow.gif" ALIGN=left>
-
- </A>
-
-
-
- Routing Events With <TT>routeEvent()</TT>
-
- </LAYER>
-
-
-
- <BR><BR>
-
- <BLOCKQUOTE>
-
- <P>By passing the mouse over the title banner, a <TT>mouseOver<TT>
-
- event is generated which is captured by the window and document
-
- objects before being passed to the layer object. If the mouse is
-
- passed over the arrow link, the <TT>mouseOver</TT> event is also
-
- captured by the window and document objects before reaching the
-
- link object.</P>
-
-
-
- <P>The following is the event path for a <TT>mouseOver</TT> event
-
- directed at the image link element:</P>
-
-
-
- <LAYER ID=linkResults></LAYER>
-
-
-
- <BR><BR>
-
- <P>And the following is the event path for a <TT>mouseOver</TT> event
-
- directed at the banner layer:</P>
-
-
-
- <LAYER ID=layerResults></LAYER>
-
- </BLOCKQUOTE>
-
-
-
- </BODY>
-
- </HTML>
-
-