Advertisement
BrU32

JS Check Your Location Constantly SRC

Mar 6th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <center>
  4. <button onclick="Loc();
  5. setInterval('Loc()',5333);">Location</button>
  6. <script>
  7. function Loc()
  8. {
  9. var loc = document.getElementById("demo");
  10. if (navigator.geolocation) {
  11. navigator.geolocation.getCurrentPosition(showPosition);
  12. } else {
  13. alert("Geolocation is not supported by this browser.");
  14. }
  15. }
  16. function showPosition(position) {
  17. alert("Latitude: " +position.coords.latitude+"\n\n"+"Longitude:" +
  18. position.coords.longitude,"Your Current Location");
  19. document.writeln("<center>Geo Location:<p>"+position.coords.latitude+'<p>');
  20. document.body.innerText=('Latitude: '+position.coords.latitude+'\nLongitude: '+position.coords.longitude+'\n');
  21. }
  22. </script>
  23. <center>
  24. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement