Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda