+ 2

geolocation not working always ...can anyone fix ? please ?

14th Jun 2018, 9:39 AM
shutthe
3 Answers
+ 2
<!DOCTYPE html> <html> <body> <p>Click the button to get your coordinates.</p> <button onclick="getLocation()">Try It</button> <p id="demo"></p> <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> </body> </html>
16th Jun 2018, 11:44 AM
shutthe
0
Hi Anirudh! Are you referring to your own code? I don't see it linked here. Best, -- Janning.
16th Jun 2018, 11:42 AM
Janning
Janning - avatar
0
it is the code i used.....
16th Jun 2018, 11:44 AM
shutthe