Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  22] [ 5]  / answers: 1 / hits: 24644  / 13 Years ago, tue, may 10, 2011, 12:00:00

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.



Any helps appreciated.



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();
}

More From » firefox

 Answers
40

For Firefox it seems that PERMISSION_DENIED is raised only if Never share is selected; if the dialog is dismissed or Not now is selected, effectively nothing happens - even on mozillas geolocation demo if you dismiss the permissions UI nothing happens.



This means that getCurrentPosition can return either because the user closed the confirmation UI, or because it successfully started it asynchronous request - there doesn't appear to be a way to discriminate between the two.



https://bugzilla.mozilla.org/show_bug.cgi?id=675533


[#92309] Monday, May 9, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sabrina

Total Points: 92
Total Questions: 92
Total Answers: 85

Location: Palestine
Member since Thu, Feb 2, 2023
1 Year ago
;