Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. <script>
  2. var x = document.getElementById("demo");
  3. function getLocation() {
  4. if (navigator.geolocation) {
  5. navigator.geolocation.getCurrentPosition(showPosition);
  6. } else {
  7. x.innerHTML = "Geolocation is not supported by this browser.";
  8. }
  9. }
  10.  
  11. function showPosition(position) {
  12. x.innerHTML = "Latitude: " + position.coords.latitude +
  13. "<br>Longitude: " + position.coords.longitude;
  14. }
  15. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement