问题
I mean, if i have a button on the web page, when a user click the button,
then can get the user's geolocation information.
but before, the browser will ask the user whether accept to use the geolocation service.
if the user reject the geolocation service, can i get the reject event?
回答1:
Yes.
Example:
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
function successCallback(){
alert('Thanks for allowing geolocation!');
}
function errorCallback(){
alert('You denied us access to geolocation...');
}
Check Geolocation API Specification for further reference.
来源:https://stackoverflow.com/questions/5512619/when-a-user-reject-the-geolocation-service-do-i-get-the-reject-event