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

166
Vistas
How to trigger a specific task when Back Button is clicked in Browser EVERYTIME?

I m trying to trigger a specific task, like change the CSS of the element when every time user clicks on the browser's Back button.

Luckily SO got my back with the code below, which triggers when a user clicks on the back button and dees the task.

But however, this trigger on the back button click only works once per page load. Hence, the function().

Can anyone help me with how to make it get triggered whenever the back button is pressed?

Code goes as :

$(function() {
    if (window.history && window.history.pushState) {
        window.history.pushState('', null, './');
        $(window).on('popstate', function() {
         // My stuff
        });
     }
});

Any help is greatly appreciated.

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

0

Use event listener , i dont know how to do it in jQuery, the code will look like this

    if (window.history && window.history.pushState) {
        window.history.pushState('', null, './');
        window.addEventListener('popstate', function() {
         // My stuff
        });
     }
});

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