Working on a project in .NET Core, I have set up a page to reload every 1-5 seconds using the meta http="Refresh" tag, which is functioning perfectly:
<meta http-equiv="Refresh" content="1" />
However, I want to separate out a piece of JavaScript code (prompting users for geolocation permission) like this:
navigator.geolocation.getCurrentPosition(position => {
const {latitude, longitude} = position.coords;
// Display map centered at latitude / longitude.
});
This section sits in the site.js file. Is there a way to prevent this code from executing during the automatic refresh, so that geolocation is only requested once when the page loads initially?
Thank you and hope this explanation makes sense!