demo · v144 · capability element
Share-on-tap
The motivating use case: a "share my location" button that uses the platform's own consent UI — no script, no permission popups when the page loads. The element fires a locate event when (and only when) the user taps it.
Origin trial
<geolocation> is behind chrome://flags/#capability-elements. JS fallback uses navigator.geolocation.<geolocation> element: checking…
tap the button. The browser's own dialog asks consent on your behalf.
the API
<geolocation precision="coarse" id="g">share my location</geolocation>
<script>
g.addEventListener("locate", e => {
console.log(e.coords.latitude, e.coords.longitude);
});
</script>