0
What is the syntax of geolocation in html?
2 ответов
+ 1
Try this js code
.
<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>
Or you can just check out this site
https://www.w3schools.com/html/html5_geolocation.asp
All the best.
0
But this code didn't worked on solo learn may I know the reason