Home / Learn HTML / HTML Geolocation and Other Browser APIs
HTML Geolocation and Other Browser APIs
HTML5 pages can ask for the visitor location, vibrate a phone, read the battery and more. The browser always asks permission first.
Definition
The Geolocation API finds the visitor's position with navigator.geolocation. The browser always asks permission first, and it works only on HTTPS. Other useful browser APIs include the clipboard, notifications, fullscreen and the share sheet.
Theory in plain words
What it is
Browser APIs give pages extra powers: location, camera, clipboard, notifications and more, always with user permission.
Why we use it
They make web pages behave like apps.
How it works
JavaScript asks the browser. The browser asks the user. If allowed, data comes back to the script.
Where it is used
- Maps and delivery apps
- Photo upload with camera
- Copy buttons
Quick quiz
1. Browsers ask this before giving location
The user must allow it.
2. Geolocation needs
Secure context is required.
3. navigator.onLine tells
true when connected.