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 invalidReason read-only property of the HTMLGeolocationElement interface returns an enumerated value representing the reason why the associated <geolocation> element is invalid (blocked), if that is the case.
When a blocker is active on a <geolocation> element, it is invalid: This means that it is prevented from functioning, either temporarily or permanently, depending on the reason.
You can query the HTMLGeolocationElement.isValid property to check whether the <geolocation> element is valid or not.
The empty string ("") if the element does not have an active blocker, or one of the following values (in priority order):
illegal_subframeThe <geolocation> element is nested inside a <fencedframe> element.
Permanent blocker.
unsuccessful_registrationMore than three <geolocation> elements have been inserted into the same document.
Temporary blocker.
recently_attachedThe <geolocation> element has only recently been attached to the DOM.
Expiring blocker.
intersection_changedThe <geolocation> element is being moved.
Expiring blocker.
intersection_out_of_viewport_or_clippedThe <geolocation> element is rendered outside or partially inside the viewport.
Temporary blocker.
intersection_occluded_or_distortedThe <geolocation> element is rendered completely inside the viewport, but it is obscured in some way, for example rendered behind other content.
Temporary blocker.
style_invalidThe <geolocation> element has some restricted styles applied to it (see Styling restrictions).
Temporary blocker.
These invalid reasons are listed in priority order, from highest to lowest. If multiple blockers are active, the invalidReason value returned will be the value representing the highest-priority active blocker.
Also note that the descriptions above include a "blocker type" for each invalid reason, which is one of the following:
PermanentThe <geolocation> element is permanently invalid until the developer updates the code to stop the blocker occurring.
TemporaryThe <geolocation> element is invalid until the blocking condition no longer occurs. After that, the temporary blocker will turn into an expiring blocker.
ExpiringThe <geolocation> element is invalid for a short period of time, after which it becomes valid again.
In this example, we provide a form control to apply different styles to a <geolocation> element that make it invalid. When each set of styles is applied, we report the invalidReason provided by the browser.
We start by including a <geolocation> element and a <div> element that we will later allow to be rendered on top of the <geolocation> element.
Next, we provide a <p> element that we will print the invalidReason generated by each set of styles.
Finally, we provide a <select> element to enable the user to choose different styling effects that invalidate the <geolocation> element.
In our styles, we start off by giving the <geolocation> element a position value of relative so that it can be positioned, and a z-index value of 1.
Next, we style our #cover <div> with position: absolute and use inset properties to place it to the right of the <geolocation> element. We also give it a z-index value of 2 so that, if our <div> is placed in the same area as the <geolocation> element, the <div> will be placed on top.
Now we define three class styles that will be applied to the <geolocation> element when the different <select> choices are selected by the user. .move-behind moves it behind the #cover <div>, .move-out moves it off-screen, and .bad-contrast gives it a bad color contrast. All three of these styles cause the <geolocation> element to become invalid.
In our script, we begin by grabbing references to the <geolocation>, <div>, <p>, and <select> elements.
Next, we add an input event listener to the <select> element. When a new select value is chosen, we set a class attribute on the <geolocation> element equal to the chosen select value, which applies one of the invalidating class styles. After a 4-second timeout, we set the class back to "", to return the <geolocation> element back to its valid state.
Finally, we include code to report the validation status changes that occur when different select values are chosen. We start by setting the <p> text content to include the invalidReason active when the page first loads. We then add a validationstatuschange event listener to the <geolocation> element. Whenever the validation status changes, we check whether the <geolocation> element is valid using HTMLGeolocationElement.isValid, and if so, print a message confirming this to the <p> element text content. If the <geolocation> element is invalid, we print the invalidReason to the <p> element text content.
See this code running live (also see the full source code). Try choosing the different invalidation options to see which invalidation reasons are reported in each case.
| The HTML Geolocation Element # dom-activationblockersmixin-invalidreason |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Feb 13, 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.