Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
Sets or retrieves whether the current event should bubble up the hierarchy of event handlers.
Syntax
HTML N/A Scripting event.cancelBubble [ = bCancel ]
Possible Values
The property is read/write with a default value of false.
false Enables bubbling. true Cancels bubbling for this event, preventing the next event handler in the hierarchy from receiving the event.
Remarks
Using this property to cancel bubbling for an event does not affect subsequent events.
Example
The following document fragment cancels bubbling of the onclick event if it occurs in the IMG object when the SHIFT key is down. This prevents the event from bubbling up to the onclick event handler for the document.
Sample Code
<SCRIPT LANGUAGE="JScript"> function checkCancel() { if (window.event.shiftKey) window.event.cancelBubble = true; } function showSrc() { if (window.event.srcElement.tagName == "IMG") alert(window.event.srcElement.src); } </SCRIPT> <BODY onclick="showSrc()"> <IMG onclick="checkCancel()" SRC="sample.gif">
Applies To
HTML N/A Scripting event
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.