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

巧了我就是萌 提交于 2020-01-14 10:11:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!