Skip to Content
Platform.Ontology

Geolocation in iframes

Lets an embedded frame ask for location only if the parent page allows it.

Asks you firstLocation and motionPositionWeb browsersWhile you use 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

BrowserStatusFirst versionReleasedNote
ChromeSupported52010-05-25Feature Policy 60, allow attribute 64, header renamed Permissions-Policy in 88
EdgeSupported122015-07-29None
FirefoxSupported3.52009-06-30None
SafariPartial52010-06-07allow attribute honored, header support partial
Safari on iPhonePartial32009-06-17None
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

API<iframe allow="geolocation">; Permissions-Policy: geolocation=(self "https://maps.example")
Permission namegeolocation
Permissions policygeolocation
Browser compat keysapi.Geolocation
How access is grantedprompt
What the user seesSame 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 gestureNo
How long it lastsPer top-level origin; delegated frames share the top-level grant
How to take it backSame site settings entry as the top-level origin
Inside an iframeDefault allowlist is self. Cross-origin frames need allow on the tag; a header of geolocation=() disables it for everyone.

Typical flow

  1. Parent sets allow="geolocation"
  2. Frame calls getCurrentPosition
  3. Browser checks the policy chain then the permission
  4. 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

TypeExampleApps
mapsA restaurant page embeds a map from Google and allows location so it can show your route.Google Maps embed
shoppingA retailer allows its own store finder frame to use location, but not an ad frame.None named
adsAn ad network frame would love to know your location, but is blocked unless the site says yes.None named
travelA booking page allows a map widget to use location for 'near me' listings.None named
gamesA game on a portal page in an embedded frame cannot see location unless the portal lets it.None named
securityA 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

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

ScoreValueMeaning
Sensitivity5 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction2 of 5How much the user has to do
Fingerprint bitsNot ratedRough 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

Sources

How well checked: Based on official documentation.

On this page