Navigator.geolocation

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The Navigator.geolocation read-only property returns a Geolocation object that gives Web content access to the location of the device. This allows a Web site or app to offer customized results based on the user's location.

Note: For security reasons, when a web page tries to access location information, the user is notified and asked to grant permission. Be aware that each browser has its own policies and methods for requesting this permission.

Syntax

geo = navigator.geolocation

Specifications

Specification Status Comment
Geolocation API
The definition of 'Navigator.geolocation' in that specification.
Recommendation Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
geolocationChrome Full support 5Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 10.6Safari Full support 5WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 4.2Samsung Internet Android Full support 1.0
Secure context requiredChrome Full support 47Edge Full support ≤79Firefox Full support 55IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support 47Chrome Android Full support 47Firefox Android Full support 55Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 5.0

Legend

Full support
Full support
No support
No support

See also