Skip to content

Latest commit

 

History

History
38 lines (16 loc) · 791 Bytes

The HTML5 Geolocation .md

File metadata and controls

38 lines (16 loc) · 791 Bytes

The HTML5 Geolocation

s

Geolocation API allows you to access the user's location information, with their permission, using JavaScript. You can use this information to display location-based content or to create location-aware web applications.

Get Location

<script> function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { alert("Geolocation is not supported by this browser."); } } function showPosition(position) { alert(`Latitude: ${position.coords.latitude}, Longitude: ${position.coords.longitude}`); } </script>