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