开发者

when a user reject the geolocation service, do i get the reject event?

开发者 https://www.devze.com 2023-02-21 01:41 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消