Create geolocation_api.js #44

Closed
rpsigh-061194 wants to merge 1 commits from patch-1 into main
Showing only changes of commit d4db451505 - Show all commits

20
geolocation_api.js Normal file
View File

@@ -0,0 +1,20 @@
<script>
var x = document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position)
{
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>