navigator.geolocation is a read-only property that returns a Geolocation object (MDN). It is the entry point to the Geolocation API for one-shot or live location reads.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use navigator.geolocation. Start with this line.
JavaScript
navigator.geolocation
Call
What it does
navigator.geolocation
Primary signature.
Built into the browser. Read navigator.geolocation on Navigator — no import required.
Library declarations
JavaScript
navigator.geolocation
Parameters
Parameter
Description
Success callback
Required. Receives GeolocationPosition
Options
Optional. enableHighAccuracy, timeout, maximumAge
Return Value
Return Value
Description
*
Geolocation object
JavaScript Examples
Example 1 — Feature-Detect
Check whether the Geolocation API is available before calling it.
watch id: 1
/* then latitude logs on updates; clearWatch(id) to stop */
How It Works
Start a watch.watchPosition registers ongoing updates.
Save the ID. The return value identifies this watch.
Log on move. Success runs again when position changes.
Clear when done. Call clearWatch(id) to stop battery drain.
Compatibility
Browser Support
Navigator.geolocation is Baseline Widely available on MDN (since about July 2015). It requires a secure context and explicit user permission. It is not Deprecated, Experimental, or Non-standard.
✓ Baseline · Widely available
Navigator.geolocation
Supported across modern desktop and mobile browsers on HTTPS. Always feature-detect and handle permission denial.
95%Modern browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
navigator.geolocationExcellent
Bottom line: Use HTTPS, request location after a clear user action, handle errors, and clear watch IDs when finished.
Frequently Asked Questions
It is a read-only Navigator property that returns a Geolocation object — the entry point to the Geolocation API for reading the device’s location (with user permission).
No. MDN marks it Baseline Widely available (since about July 2015). It is not Deprecated, Experimental, or Non-standard. It does require a secure context (HTTPS / localhost).
Yes. When your page requests location, the browser asks for permission. Policies and UI differ by browser. Always handle denial gracefully.
Call navigator.geolocation.getCurrentPosition(success, error, options). The success callback receives a GeolocationPosition with coords.latitude and coords.longitude.
watchPosition(success, error, options) keeps updating as the device moves and returns a watch ID. Stop updates with clearWatch(id).
No. The property is read-only. You call methods on the returned Geolocation object.