spacer

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

home / experts / javascript / column74


Netscape 6, Part III: The Event Model

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Setting Events in Internet Explorer

In order to understand the new event model in Netscape 6, you need also to refresh your knowledge of how it is done in Internet Explorer. Internet Explorer introduced the concept of event bubbling. As oppose to Netscape Navigator 4.x where events dive from the window object to the target object, an event in Internet Explorer bubbles from the target object outwards to the window object, propagating through all involved objects along the way. Each object can intercept the event and process it. The order of event interception is determined by the bubbling order. The target object is always first, followed by any higher objects in the hierarchy. Let's take an example.

Our sample paragraph includes a single sentence, part of it in bold. We attach an onClick event handler to both the paragraph tag (<P>) and the bold tag (<B>):

onClick = "alert('Thank you for clicking...!');

Both event handlers pop up an alert box. First, is the bold text's alert box ('Thank you for clicking somewhere in the bold section!'), followed by the paragraph's alert box ('Thank you for clicking somewhere in the paragraph!'). You can see by the order of the alert boxes that the bold text object processes the event before the paragraph object. Here is the full listing of the HTML code:

<BLOCKQUOTE>
<P onClick="alert('Thank you for clicking somewhere in
  the paragraph!')">
This is a paragraph, and
<B onClick="alert('Thank you for clicking somewhere in
  the bold section!')">
these are bold words in the paragraph</B>.
</P>
</BLOCKQUOTE>

And here is the result. Try clicking the bold text:

This is a paragraph, and these are bold words in the paragraph.

Next: How to set event handlers in Netscape 6

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: January 1, 2001
Revised: January 1, 2001

URL: http://www.webreference.com/js/column74/3.html