Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!