views:

463

answers:

2

I am writing a DOM inspector, something like what firebug is doing but sure very simpler "just inspect elements".

What i want to do is when the user click on an element it will make some functions i wrote, and in same time i don't want this element to do any other pre attached events.

Means:

If the user inspected anchor element, and then click on it, it will do my function and will do go to the anchor href location.

And the same case for all elements such as input, selects, ....

Seams that i will need to disable the mouse down event but i don't know the right way to do that.

Any advice?

+3  A: 

In your onClick handler, return false?

jeffamaphone
+1 did it before and didn't work but this time it worked seams i was doing something wrong before, thanks a lot @jeffamaphone
Amr ElGarhy
Can that stop events being fired from an iframe inside the form?
rahul
@Phoenix: I don't have enough context to answer your question. Consider opening a new question and pasting in some code to demonstrate what you are doing.
jeffamaphone
A: 

You can attach a single onClick event to the body element and from there find the event.originalTarget element to see what the user actually clicked on. Then you can stop propagation to prevent the original element's event from being fired.

Bryan Migliorisi
can you give a simple example with code?
Amr ElGarhy