Web Development & Design Foundations with HTML5

Skip to Content 8th Edition

Geolocation Example

The Geolocation API allows your web page visitors to share their geographic location. Your visitor's location may be determined by their IP address, wireless network connection, local cell tower, or GPS hardware depending on the type of device and browser.
Note: This example of the Geolocation API works best on a browser other than Google Chrome. As of Chrome 50, the Geolocation API will only work on secure contexts such as HTTPS. If a site is hosted on an non-secure origin (such as HTTP) the requests to get the users location will no longer function.