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

173
Vistas
javascript: localStorage.getItem() returns value on same page, returns null on next page

Sorry for this easy question:

I am doing:

  localStorage.setItem("eventID", product); // set item to a storage so that we can retrive next page 
  var tests = localStorage.getItem('eventID');

  console.log(tests)

I can see in the console that it retrieves the value I stored into it.

Now when I am on the next page:

var eventID = localStorage.getItem('eventID');
console.log(eventID)

It is returned as null.

How can that be?

This is how I move to the next page:

<p class="regText">Please sign in with your account. If you haven't used the app <a href="page_createAcc.html">click here.</a></p>

Edit this is the full code:

Page1:

getURLArguments();

function getURLArguments(){


  const queryString = window.location.search;
  const urlParams = new URLSearchParams(queryString);
  const product = urlParams.get('eventID')

  localStorage.setItem("eventID", product); // set item to a storage so that we can retrive next page 
 
}

( I can see it working with console, so the issue is not with the arguments)

Page 2:

getEventID();

function getEventID(){
  var eventID = localStorage.getItem('eventID');
  console.log(eventID)

}

The page change comes from html (see above).

I tried running this within single folder and on server. Neither works.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found out that above code is working fine on Safari but not on Firefox. It works on firefox, only when the pages are hosted live. On a local machine, it just didnt work. But the code is correct.

about 4 years ago · Juan Pablo Isaza Denunciar
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