Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
¿Cómo enumerar los detectores de eventos del elemento html en tiempo de ejecución sin las herramientas de desarrollo?

Existe esta respuesta: ¿puedo examinar y modificar mediante programación los controladores de eventos de Javascript en elementos html? pero no proporciona la solución de tiempo de ejecución

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No hay ninguna API directa para esto, pero se puede acceder a ella de forma intrusiva.

Al anular HTMLElement.prototype.addEventListener , podemos capturar eventos agregados y almacenarlos en una matriz, por ejemplo.

 const listeners = [] const originalAddEventListener = HTMLElement.prototype.addEventListener HTMLElement.prototype.addEventListener = function(type, listener, options) { listeners.push({ element: this, type, listener, options }) // call the original listener with current this and provided arguments return originalAddEventListener.call(this, type, listener, options) }

Fragmento completo con ejemplo:

 const listeners = [] const originalAddEventListener = HTMLElement.prototype.addEventListener HTMLElement.prototype.addEventListener = function(type, listener, options) { listeners.push({ element: this, type, listener, options }) return originalAddEventListener.call(this, type, listener, options) } document.querySelector('p').addEventListener('click', () => { console.log('clicked') }, false) document.querySelector('button').addEventListener('click', () => console.log(listeners))
 p { width: 100px; height: 100px; background: red; color: white; }
 <button>list listeners</button> <p>click me</p>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!