Why this geolocation API isn't working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why this geolocation API isn't working?

<!DOCTYPE html> <html> <head> <title>LOCATION</title> </head> <body bgcolor="#011f45"> <h1 id="empty"></h1> <button type="button" onclick="myPosition()"><i>CLICK ME!</i><br>GET YOUR LOCATION</button> <script> var h=document.getElementById("empty"); function myPosition(){ if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(showlocation); } } function showlocation(position){ h.innerHTML="long:"+position.coords.longitude; } </script> </body> </html>

17th Aug 2020, 8:00 AM
Yash Siddque Shahittya
Yash Siddque Shahittya - avatar
1 Answer
+ 2
you need the page to be in https. location is very sensitive piece of information, that's why https is the mininum
17th Aug 2020, 8:05 AM
Taste
Taste - avatar