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

160
Vistas
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 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