簡單的問題..如果用戶選擇不允許geolocator彈出,我該如何設置重定向?如果允許和錯誤我已經涵蓋。工作正常。但我不知道如何設置不允許選擇。jquery mobile geolocation
function showLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
//window.location = "/restaurant/latitude/40.714269/longitude/-74.005972/";
window.location = "/restaurant/";
}
function errorHandler(err) {
if(err.code == 1) {
alert("Error: Can not access!");
}else if(err.code == 2) {
alert("Error: Position is unavailable!");
}
}
function getLocation(){
if(navigator.geolocation){
// timeout at 60000 milliseconds (60 seconds)
var options = {timeout:60000};
navigator.geolocation.getCurrentPosition(showLocation, errorHandler, options);
}else{
alert("Sorry, browser does not support geolocation!");
}
}
這工作。我不知道沒有訪問/錯誤1實際上是不允許選擇.. – user154107