<geolocation watch></geolocation>HTMLGeolocationElement: watch property / notebook
HTMLGeolocationElement: watch property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const geo = document.querySelector("geolocation");
console.log(geo.watch); // true<geolocation watch></geolocation>
<p id="output"></p>const outputElem = document.querySelector("#output");
const geo = document.querySelector("geolocation");
console.log(geo.watch); // truegeo.addEventListener("location", () => {
if (geo.position) {
outputElem.textContent += `(${geo.position.coords.latitude},${geo.position.coords.longitude}), `;
} else if (geo.error) {
outputElem.textContent += `${geo.error.message}, `;
}
});