<geolocation autolocate></geolocation>HTMLGeolocationElement: error property / notebook
HTMLGeolocationElement: error 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");
geo.addEventListener("location", () => {
if (geo.position) {
console.log(
`(${geo.position.coords.latitude},${geo.position.coords.longitude})`,
);
} else if (geo.error) {
console.log(geo.error.message);
}
});