开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜