Professional Development

Using Javascript to Find Your Current Location

How accurately can Internet browsers determine your physical location? Pretty accurately apparently, and with just a couple lines of code. Take this example: <!DOCTYPE html> <html> <body> <button onclick=”whereAmI()”>Where am I?</button> <p id=”data”></p> </body> </html> Insert this script: var x = document.getElementById(“data”); function whereAmI() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } } function showPosition(position) { x.innerHTML… Continue reading Using Javascript to Find Your Current Location