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

107
Visualizações
Unable to share Local-Storage context into the same Web App

I'm developing my first Web-App that will be embedded into an Android Web-View. The App is entirely done using standard HTML and JavaScript, with no special requirements nor libraries, only jQuery is used).

The first time the App is opened, the content to be displayed is downloaded using Ajax and saved to LocalStorage, so it can be accessed offline. When the application is uploaded to a web server (ex: myserver.com), LocalStorage works perfectly, this is, that I save a string in one page:

localStorage.setItem("MYVAR", "Hello World!");

and it is accessible from other html pages:

console.log(localStorage.getItem("MYVAR"));

But when the App is opened directly in the browser (local browsing using file://), to emulate the bahaviour of a Web-View, then it seems that the context for LocalStorage is lost, being different on each page, so LocalStorage is not shared and when a variable is created in one page, is not visible in other pages (but when uploaded to a server everything works fine).

For accessing remote files through Ajax and avoid issues in running JS files, I'm using this:

<meta http-equiv="Content-Security-Policy" content="script-src 'strict-dynamic' 'nonce-ABCD0123456'" />
<script nonce="ABCD0123456" src="myscript.js"></script>

I'm not sure whether this is related to Security policies, manifest settings, but I'm pretty sure that I'm missing something.

Any help will be much appreciated.

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