With Geolocation API, the user can provide their location to web sites. You can access it with the navigation.geolocation object.
Check if the browser supports the API:
To get the current position:
If you want to follow the location in case it changes then you can use the watchPosition() method. It also returns a unique id which you can use to identify the requested position.