html5 - Is there a way of detecting whether a user has already given permission to use navigator.geolocation? -
apart setting cookie first time round, there way of detecting whether user has given permission navigator.geolocation return lat/long of browser?
if there is, , same across browsers or different across browsers?
this subject has been partially answered elsewhere
according geolocation api – chrome / safari – permission management , visual differences, chrome asks revokable one-time permission. haven't finished reading article, seem storage of permissions not purely-chrome thing do.
what using localstorage should supported html5 browsers (that support geolocation)
if (navigator.geolocation) { navigator.geolocation.getcurrentposition(successfunction, errorfunction); } //get latitude , longitude; function successfunction(position) { var lat = position.coords.latitude; var long = position.coords.longitude; localstorage['authorizedgeolocation'] = 1; } function errorfunction(){ localstorage['authorizedgeolocation'] = 0; } function checkauthorizedgeolocation(){ // can use function know if geolocation allowed if(typeof localstorage['authorizedgeolocation'] == "undefined" || localstorage['authorizedgeolocation'] == "0" ) return false; else return true; }
and check using below function :
alert(checkauthorizedgeolocation());
Comments
Post a Comment