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?