本文介绍了如果用户拒绝在firefox中共享地理位置,则函数失败不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这个javascript代码。在safari和chrome,如果用户拒绝共享位置,它将失败的功能,因为它应该;然而,在Firefox中,它不是。
So I have this javascript code. In safari and chrome, if user declines to share location, it goes to fail function as it should; however, in Firefox, it does not.
任何帮助赞赏。
function initGeolocation()
{
if( navigator.geolocation )
{
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition( success, fail );
}
else
{
alert("Sorry, your browser does not support geolocation services.");
}
}
var map;
function success(position)
{
var longIDText = document.getElementById('longID');
var latIDText = document.getElementById('latID');
longIDText.value = position.coords.longitude;
latIDText.value = position.coords.latitude;
document.getElementById('coordSubmitID').click();
}
function fail(error)
{
alert("FAAAAAAAAAAIIIIIIIIIL")
var zip_code ;
while (true){
// Could not obtain location
zip_code = prompt("Please enter your current address or zip code","");
if ( zip_code == "" ) {
alert(zip_code +" is not a valid address. Please try again.");
}
else{
break;
}
}
var zipIDText = document.getElementById('zipID');
zipIDText.value = zip_code;
document.getElementById('coordSubmitID').click();
}
推荐答案
=https://bugzilla.mozilla.org/show_bug.cgi?id=591745>似乎 PERMISSION_DENIED
只有提升如果选择从不共享如果对话框被关闭或选择不现在,即使在
这篇关于如果用户拒绝在firefox中共享地理位置,则函数失败不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!