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

A

Andrew Poulos

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
 
B

Bjoern Hoehrmann

* Andrew Poulos wrote in comp.lang.javascript:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top