when a user reject the geolocation service, do i get the reject event?
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?
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.
精彩评论