Geolocation in iframes
Lets an embedded frame ask for location only if the parent page allows it.
In one line
Can let an embedded map ask for your location, only if the host page allows
Lets an embedded frame ask for location only if the parent page allows it.
Controls whether ad, map or widget frames can see where the person is. The default blocks cross-origin frames so third parties cannot request location through a host page.
What it can and can't do
What the user does: You tap Find me or Use my location inside an embedded map or widget
It can
- Ask for location from inside an embedded frame, if the host page lets it
- Show a prompt that names the main site
- Give the embedded map your position after you allow it
It cannot
- Ask for location by default when it comes from a different site; that is blocked
- Skip your Allow
- Get location without the host page's permission setting
How it differs between platforms: Chrome, Edge and Firefox support it fully. Safari support is partial.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 5 | 2010-05-25 | Feature Policy 60, allow attribute 64, header renamed Permissions-Policy in 88 |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 3.5 | 2009-06-30 | None |
| Safari | Partial | 5 | 2010-06-07 | allow attribute honored, header support partial |
| Safari on iPhone | Partial | 3 | 2009-06-17 | None |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | <iframe allow="geolocation">; Permissions-Policy: geolocation=(self "https://maps.example") |
| Permission name | geolocation |
| Permissions policy | geolocation |
| Browser compat keys | api.Geolocation |
| How access is granted | prompt |
| What the user sees | Same prompt as top-level, worded for the top-level site; the grant is delegated to the iframe origin. |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | No |
| How long it lasts | Per top-level origin; delegated frames share the top-level grant |
| How to take it back | Same site settings entry as the top-level origin |
| Inside an iframe | Default allowlist is self. Cross-origin frames need allow on the tag; a header of geolocation=() disables it for everyone. |
Typical flow
- Parent sets allow="geolocation"
- Frame calls getCurrentPosition
- Browser checks the policy chain then the permission
- Prompt or silent result per stored decision
Data you get
What comes back: Same GeolocationPosition as top-level
Shape: object
How often: same as Geolocation
No individual data fields. The signal is the access itself.
Technical limits
- Cross-origin frames cannot request location by default
- Policy cannot grant more than the person granted
- Sandboxed frames without allow-same-origin may fail
The story
What it is
Decides whether an embedded ad, map or widget on a page may see your location.
For you
You may see a location prompt that names the main site, not the embedded widget. By default, third party frames cannot ask at all. You usually never notice this protection working.
For makers
Maps, store finders and ads are often embedded from another company. The page owner must explicitly allow location for them, which keeps other companies from watching you through an ad frame.
Where you see it
| Type | Example | Apps |
|---|---|---|
| maps | A restaurant page embeds a map from Google and allows location so it can show your route. | Google Maps embed |
| shopping | A retailer allows its own store finder frame to use location, but not an ad frame. | None named |
| ads | An ad network frame would love to know your location, but is blocked unless the site says yes. | None named |
| travel | A booking page allows a map widget to use location for 'near me' listings. | None named |
| games | A game on a portal page in an embedded frame cannot see location unless the portal lets it. | None named |
| security | A site blocks location in all embeds to keep ad fraud and spying away. | None named |
Risks
- Embeds can overreach if allowed
- Often misconfigured
What the platform says
- MDN (standards docs): Permissions Policy. Describes a way for a page to allow or block features like location for embedded frames.
Good uses and abuse
Legitimate uses
- Embedded store locators
- Map widgets
Known abuse
- Hidden ad frames requesting location when a publisher sets allow="geolocation *"
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 5 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 2 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough identifying entropy, when known |
History
- 2017-07, Chrome 60: Feature Policy header introduced with a geolocation feature
- 2018-01, Chrome 64: iframe allow attribute ships
- 2021-01, Chrome 88: Header renamed from Feature-Policy to Permissions-Policy
Related capabilities
Related
- Geolocation. Can find where your device is, once or while the page is open
- Permissions Policy and iframe allow. Can turn features off for itself and its embedded frames
Sources
How well checked: Based on official documentation.