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

99
Visualizações
classlist.remove when going back in history

I made a small page-transition with javascript.

When the user clicks a link, a black div gets the class "slide" which triggers the animation going on opacity from 0 to 1.

Then, it triggers the link to the next page, where a black div animates from opacity 1 to 0. This works just fine.

But when I go back in history the div still has the class "slide", so that I only see a black rectangle.

When I put a classList.remove("slide") in the setTimeout this problem is gone but I see the page for a millisecond when switching to the other page.

Does anyone have an idea how I can solve this issue?

for (let i = 0; i < link.length; i++) {
    link[i].addEventListener("click", (e) => {
        e.preventDefault();
        transition.classList.add("slide");
        setTimeout(() => {
            window.location = link[i].href;
        }, 450);
    });
} 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution: performance.navigation.type as mentioned in the second answer here: How to force reloading a page when using browser back button?

if(performance.navigation.type == 2){
   location.reload(true);
}
about 4 years ago · Juan Pablo Isaza Relatório
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