Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to get your coordinates.</p> <button onclick="getLocation()">Try It</button> <p id="demo"></p> <script> var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.watchPosition(showPosition); } else { x.innerHTML = "Geolocation is not supported by this browser.";} } function showPosition(position) { x.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </body> <!-- Mirrored from www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation_watchposition by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:20:58 GMT --> </html>
Result:
Try it Yourself - © w3schools.com