下面的代碼在Firefox但不是不工作的谷歌瀏覽器:W3C地理位置API在Chrome
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<script type="text/javascript">
var successCallback = function(data) {
console.log('latitude: ' + data.coords.latitude + ' longitude: ' + data.coords.longitude);
};
var failureCallback = function() {
console.log('location failure :(');
};
var logLocation = function() {
//determine if the handset has client side geo location capabilities
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(successCallback, failureCallback);
}
else{
alert("Functionality not available");
}
};
logLocation();
setTimeout(logLocation, 5000);
</script>
</head>
<body>
<p>Testing</p>
<body>
</html>
這是怎麼回事?我認爲谷歌瀏覽器應該支持W3C地理定位API。完美的我
啊,第二個讓我。很高興知道。謝謝您的幫助。 – LandonSchropp 2011-05-31 00:48:18
不客氣:) – 2011-05-31 01:08:05
謝謝。第二個選項有助於;-) – Sopo 2015-07-27 07:16:38