<body > <p id="demo">Click the button to get your position:</p> <button onclick="getLocation()">Get your Location</button> <script type="text/javascript"> var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); } else { x.innerHTML = "Geolocation is not supported by this browser."; } } function showPosition(position) { var latitude = position.coords.latitude var longitude = position.coords.longitude; document.getElementById("Label1").innerHTML = latitude; document.getElementById("Label2").innerHTML = longitude; } function showError(error) { if (error.code == 1) { x.innerHTML = "User denied the request for Geolocation." } else if (err.code == 2) { x.innerHTML = "Location information is unavailable." } else if (err.code == 3) { x.innerHTML = "The request to get user location timed out." } else { x.innerHTML = "An unknown error occurred." } } </script> <form id="form1" runat="server">
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.