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

94
Vistas
Updating content with onpopstate

I have a hub that loads pages in to a div with the class 'main', and trying to work out how to be able to go back and forth using browser buttons. I have the following on the settings page:

clickHandler(null, null, 'settings');

This calls the following:

function clickHandler(one,two,three) {
    history.pushState(one, two, three);
}

I know that up to this part, it is passing the 'settings' variable as the address bar is showing /settings when navigating back. So to try and get settings.php to load in to 'main' I am trying the following:

function updateContent(data) {
    if (data == null)
    return;
    console.log(data);
    $(".main").load(data+'.php');   
}

window.onpopstate = function(event) {
  console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
  updateContent(document.location)
};

However, unless I press back twice really quickly, it's not loading the correct page.

about 4 years ago · Santiago Trujillo
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