HTML5一步一步走——地理应用(六)地理信息应用获取自己的位置:function $(id) { return document.getElementById(id); }window.onload = function() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(pos) { $("lat").innerHTML = pos.coords.latitude;//纬度 $("lon").innerHTML = pos.coords.longitude;//经度 $("alt").innerHTML = pos.coords.altitude;//高度 $("accuracy").innerHTML = pos.coords.accuracy; $("altitudeAccuracy").innerHTML = pos.coords.altitudeAccuracy; $("heading").innerHTML = pos.coords.heading; $("speed").innerHTML = pos.coords.speed; $("timestamp").innerHTML = pos.timestamp; // $("status").innerHTML = JSON.stringify(pos); }, function() {}, {enableHighAccuracy:true, maximumAge:600000} ); } else { $("status").innerHTML = 'No Geolocation support for your Browser'; }}