Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <center>
- <button onclick="Loc();">Location</button>
- <script>
- function Loc()
- {
- var loc = document.getElementById("demo");
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(showPosition);
- } else {
- alert("Geolocation is not supported by this browser.");
- }
- }
- function showPosition(position) {
- alert("Latitude: " +position.coords.latitude+"\n\n"+"Longitude:" +
- position.coords.longitude,"Your Current Location");
- document.writeln("<center>Geo Location:<p>"+position.coords.latitude+'<p>');
- document.writeln(position.coords.longitude+'<p>');
- }
- </script>
- <center>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement