Revision: 31002
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 27, 2010 04:31 by iamjpg
Initial Code
<!DOCTYPE html> <html> <head> <script> var messageDiv = document.getElementById('message'); function initLocation ( ) { // Try HTML5-spec geolocation: http://dev.w3.org/geo/api/spec-source.html var geolocation = navigator.geolocation; if (geolocation) { // Try Catch try { // getCurrentPosition function as stated in the spec navigator.geolocation.getCurrentPosition( successCallback, errorCallback ); } catch (err) { messageDiv.innerHTML = 'Error'; } } else { messageDiv.innerHTML = 'Your browser is not capable of looking up your location.'; } } function successCallback ( location ) { message.innerHTML="<p>Longitude: " + location.coords.longitude + "</p>"; message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>"; message.innerHTML+="<p>Accuracy: " + location.coords.accuracy + "</p>"; } function errorCallback ( ) { messageDiv.innerHTML = 'There was an error looking up your position'; } </script> </head> <body onload="initLocation()"> <div id="message">Looking Up Location</div> </body> </html>
Initial URL
http://dev.w3.org/geo/api/spec-source.html
Initial Description
Simple Javascript test of the HTML 5 geolocation API spec
Initial Title
Basic Javascript Geolocation Script (HTML 5 Spec)
Initial Tags
javascript
Initial Language
JavaScript