| Subcribe via RSS

stopPropagation() and cancelBubble

May 14th, 2008 | No Comments | Posted in javascript by dreamluverz


Another way of doing the cancelBubble:

function dropButtonClick(e) { if( typeof( e ) == "undefined" && typeof( window.event ) != "undefined" ) e = window.event; // do things.... if (typeof( window.event ) != "undefined" ) { // IE e.cancelBubble=true; } else { // Firefox e.stopPropagation(); } }

source: http://blogs.charteris.com/blogs/edwardw/default.aspx

Tags: , ,

cancelBubble

May 14th, 2008 | No Comments | Posted in javascript by dreamluverz

I have this function but something was wrong with firefox. I got undefine value. After taking a closer look in my code I forgot to pass the 'event' parameter on my function.



function dps_cancel_bubble(e)
{
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}

so you need to call it like this.

<img src=”" onlickc=”dps_cancel_bubble(event)”> DONT EVER FORGET TO PASS event or else you’ll get crazy looking for the bug :P I almost did :lol:

Tags: , , , , , ,