Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
How to ensure that all onclick events on clicked domnode got executed before the page navigates to another page

We are working on an Open Source Chrome extension: Digital Assistant Client

Product Demo:

Part 1: https://www.youtube.com/watch?v=Iz2WgKY0fhc

Part 2: https://www.youtube.com/watch?v=i0_MNfBnYfM

We are having trouble in getting our onclick event handler executed when the page is navigated to another page.

I want to invoke all the onclick event handlers attached to a domnode that the user has clicked before the page gets navigated to another page so that our functionality gets executed. The solution should work for any framework that cancels the bubbling of the onclick event handlers.

There are some questions already raised by some people as given below

  1. How to ensure that a function is executed completely, before navigating to another page?
  2. How to execute onclick before navigating to a different page?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can probably monkey-patch addEventListener on the DOM Node, capture the event handlers that get registered later, and maintain a list of those.

const originalEventListener = DOMNode.addEventListener;
DOMNode.addEventListener = (type, callback) => {
  const clicksHandler = [];
  if(type === 'click'){
    clicksHandler.push(callback);
    originalEventListener.call(DOMNode, type, callback);
  }
}

You can probably use beforeunload event to make sure all the clicksHandler are called once again before user navigates away.

window.onbeforeunload = (e) => {
  clickHandler.forEach((handler) => handler.call(...))
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

you just have to call the event on that element.

const button1 = document.getElementBy....

button1.click()
about 4 years ago · Juan Pablo Isaza Denunciar

0

add alert before navigation inside click method, so alert will notify you.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda