0

What is the syntax of geolocation in html?

25th Apr 2020, 8:30 PM
Rushikesh Vasande
Rushikesh Vasande - avatar
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.
25th Apr 2020, 8:35 PM
NITESH KUMAR
NITESH KUMAR - avatar
0
But this code didn't worked on solo learn may I know the reason
13th Oct 2021, 6:08 AM
vinay kumar
vinay kumar - avatar