Advertisement
BrU32

JS Display Current Local Geo Location SRC

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