1

I have my own page where I load an external third-party JavaScript that analyzes my DOM. The problem I am facing is as follows. I install some event listeners ('keypress', 'input', 'click') but after I append mentioned script (and she performs some computation), some of my listeners are not working any more. To be precise, 'click' listener is intercepting click events as expected, but other two are not intercepting anything. Is there a way for that external script to interfere with my listeners?

Btw., I am setting useCapture to true when installing my listeners, like this:

document.addEventListener('input', function...., true);
...

I don't have any other code to provide you with.

P.S. I am not able to play with the external code since it is obfuscated. P.P.S. Installing the handlers again did not help.

rene
  • 37,946
  • 78
  • 99
  • 132
bellpeace
  • 1,367
  • 1
  • 13
  • 34

1 Answers1

1

It is possible, although quite unlikely, that the third-party code is capturing the event(s) before and and stopping it propagating (e.stopPropagation()). This would require the code attaching a listener to the same event on a parent element in the capturing phase.

Without more code to see, particularly this third-party code, it's hard to find the actual problem.

Adam Heath
  • 4,361
  • 1
  • 33
  • 50
  • I tried installing the listeners on the window, but that didn't help. I know it is hard without the code, but it would be helpful to find out possible causes, which could guide me. This was helpful for sure. – bellpeace Aug 29 '12 at 00:56
  • Take a look at the top answer on this question: http://stackoverflow.com/questions/7338193/using-chrome-how-to-find-whos-binded-to-an-event That's all I can suggest trying without more detail. – Adam Heath Aug 29 '12 at 01:04
  • 1
    @AdamHeath—worth pointing out that [stopPropagation](http://www.w3.org/TR/DOM-Level-3-Events/#events-event-type-stopPropagation) stops an event from propagating to other elements, it doesn't stop listeners on the current element (i.e. other [candidate event listeners](http://www.w3.org/TR/DOM-Level-3-Events/#glossary-candidate-event-handlers)) from being called. – RobG Aug 29 '12 at 01:59