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

134
Visualizações
navigator.geolocation.watchPosition() doesn't log position when phone display is off

Say I have a website with this code:

<script>
const watchID = navigator.geolocation.watchPosition((position) => {
    el = document.querySelector('#log');
    el.innerHTML = el.innerHTML + position.coords.latitude + ',' + position.coords.longitude + '<br>';
});
</script>

<div id="log"></div>

The code runs without issue, on my phone, when the display is on and I'm currently viewing the page in the browser. But if I turn the screen off or go to another app (whilst not closing the browser) I code stops running. It's like it only runs when it has focus.

Am I correct in assuming that this is the key difference between a mobile app and a webpage?

about 4 years ago · Santiago Gelvez
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