Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The initialPermissionStatus read-only property of the HTMLGeolocationElement interface returns an enumerated value representing the permission status for the geolocation feature when the page first loads.
If you want to access the current permission status for the geolocation feature, use the HTMLGeolocationElement.permissionStatus property.
An enumerated value, which can be one of:
grantedThe user previously granted permission for the browser to use the geolocation feature, either via the <geolocation> element or some other mechanism. When using the <geolocation> element, this means that the user previously pressed the rendered button and selected an "allow" option.
If the <geolocation> element has its autolocate attribute set to true, and permission was previously granted, the browser will start to request location data as soon as the page loads, without requiring the user to press the button.
deniedThe user previously denied permission for the browser to use the geolocation feature, either via the <geolocation> element or some other mechanism. When using the <geolocation> element, this means that the user previously pressed the rendered button and selected a "don't allow" option.
promptThe user has not previously granted or denied permission for the browser to use the geolocation feature. When using the <geolocation> element, this means that the user has not previously pressed the rendered button.
In this example, we use initial permission status to print an appropriate message to the screen informing the user what action the <geolocation> button will perform.
We include a <geolocation> element and two <p> elements, one to output permission status messages to, and one to output location data to.
In our JavaScript, we start by grabbing references to all three of our HTML elements:
Next, we include an if...else if structure that checks what the initialPermissionStatus is, and prints a status message to the screen to inform the user what the status is, what they need to do to use the app, and what the button will do when pressed.
Finally, we add a location event listener to the HTMLGeolocationElement object, to detect when the location data request is returned. If the data is returned successfully, we access it via the HTMLGeolocationElement.position property, and print the latitude and longitude values to the output paragraph. If the data request fails, we access the error via the HTMLGeolocationElement.error property and print it to the output paragraph.
See the example running live (source code). Try selecting the <geolocation> button multiple times, choosing a different option from the resulting dialog each time and reloading the page, to see how the output message changes to reflect the situation.
| The HTML Geolocation Element # dom-powerfulfeatureobserver-initialpermissionstatus |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 2, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.