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()); 

this jsfiddle if need check


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -