当用户拒绝地理定位服务时,是否收到拒绝事件? [英] when a user reject the geolocation service, do i get the reject event?

查看:117
本文介绍了当用户拒绝地理定位服务时,是否收到拒绝事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,如果我在网页上有一个按钮,当用户点击按钮时,

就可以获得用户的地理位置信息。



但之前,浏览器会询问用户是否接受使用地理定位服务。



如果用户拒绝地理定位服务,我可以得到拒绝事件吗?

解决方案

是。



示例:

  navigator.geolocation.getCurrentPosition(successCallback,errorCallback); 

函数successCallback(){
alert('Thanks for geolocation!');
}

函数errorCallback(){
alert('您拒绝我们访问地理位置...');
}

检查地理位置API规范以供进一步参考。


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.

这篇关于当用户拒绝地理定位服务时,是否收到拒绝事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆