Firebug lite javascript events

48 views
Skip to first unread message

Mike Priest

unread,
Sep 30, 2013, 6:59:53 PM9/30/13
to fir...@googlegroups.com
I am working on a firebug like javascript element selector, but cannot figure out how to stop all JavaScript events from firing when clicked. The firebug lite plugin (https://getfirebug.com/firebuglite) is doing exactly what I want, but cannot figure out what they are doing.
Any help would be appreciated.

Senario:
  • User selects element inspector
  • User clicks on element
  • onClick, mousedown, mouseup should NOT fire

I have tried the following with no luck:

function stopEvents(el){

    for(var key in window) {
        if (key.indexOf("on") == 0) {
            el.addEventListener(key.substr(2), stop, false);
        }
    }
}

function StopEvent(pE)
{
    stopEvents(pE);

    if (!pE)
     if (window.event)
       pE = window.event;
     else
       return;
  if (pE.cancelBubble != null)
     pE.cancelBubble = true;
  if (pE.stopPropagation)
     pE.stopPropagation();
  if (pE.preventDefault)
     pE.preventDefault();
  if (window.event)
     pE.returnValue = false;
  if (pE.cancel != null)
     pE.cancel = true;
}





Sebastian Zartner

unread,
Sep 30, 2013, 7:47:05 PM9/30/13
to fir...@googlegroups.com
The Firebug inspector doesn't stop all events of an object, it only captures the click event. If that's enough for you, you can simply do that by setting the third parameter of addEventListener() to true instead of false to trigger at the capturing phase of the event and then cancel the event.

Sebastian
Reply all
Reply to author
Forward
0 new messages