BrU32

JS Geolocation Loop If Page Is Topmost SRC

Jul 26th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <center>
  5. <body onmousemove="Loc();">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. document.write("Geolocation is not supported by this browser.");
  14. }
  15. }
  16. function showPosition(position) {
  17. document.body.innerHTML=document.body.innerHTML+("<center>Geo Location:<p>Latitude: "+position.coords.latitude+'<p>');
  18. document.body.innerHTML=document.body.innerHTML+("Longitude: "+position.coords.longitude+'<p>');
  19. }
  20. </script>
  21. <center>
  22. </html>
Advertisement
Add Comment
Please, Sign In to add comment