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

162
Visualizações
localStorage Inconsistent on chrome

I'm working on a website that uses the clients localStorage to save the theme. The theme works by using the hue-rotate background filter, on firefox the code seems to work fine, (although the background-filter is invalid in firefox) but in chrome it is inconsistent, when I reload, there seems to be a 50/50 chance that it will display the correct theme.

https://www.redmonster12.repl.co

theme scripts:

var cStore = parseInt(localStorage.getItem("theme"));
var themeID;
if (cStore == 1) {
  themeID = 1;
} else {
  themeID = 0;
}

function invert(change) {
  var element = document.getElementById("pane");
  element.classList.toggle("invert");
  themeID += change;
  localStorage.setItem("theme", themeID % 2);
  console.log(themeID % 2);
}

function theme() {
  if (themeID % 2 == 1) {
    invert(0);
  }
  console.log(themeID % 2);
}

theme();

Button in the HTML:

<button onclick="invert(1)" class="theme"></button>

The element css used to change the theme:

.pane {
  margin: 0;
  padding: 0;
  position: fixed;
  width: 100%;
  height: 100%;
  opacity: 1;
  backdrop-filter: hue-rotate(180deg);
  transition: 0.5s all ease;
  z-index: -1;
}
.pane.invert {
  opacity: 0;
}
about 4 years ago · Juan Pablo Isaza
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