Connecting Tech Pros Worldwide Forums | Help | Site Map

removeEventListener when you don't know the object or function name

Andrew Poulos
Guest
 
Posts: n/a
#1: Sep 1 '08
Is there a way to call removeEventListener when you don't know what
events may have been added?

With something like
object.onclick = blah;
I could run through every element in the page, search for onclick and
set it to null.

When people use addEventListener and don't keep a record of the events
they add it to I don't know how to find them.

Andrew Poulos

Bjoern Hoehrmann
Guest
 
Posts: n/a
#2: Sep 1 '08

re: removeEventListener when you don't know the object or function name


* Andrew Poulos wrote in comp.lang.javascript:
Quote:
>Is there a way to call removeEventListener when you don't know what
>events may have been added?
No. You could try to override the addEventListener function before any
listener is added and use that information, or you could generate a list
of "all" probable event names and use them all, but other than that this
is not possible. Browser-internal APIs might help you, if this is for a
browser extension of some sort.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Closed Thread