Chrome and HTML5 GeoLocation denial callback


For timeout callback in Google Chrome, try the following code:

_callback = false;
function successCallback(position) {
   _callback = true;
   console.log('success');
}

function errorCallback(error) {
   _callback = true;
   alert('error');
}
setTimeout(function(){if(!_callback)console.log('ignored')}, 20000);

navigator.geolocation.getCurrentPosition(
   successCallback,
   errorCallback,
   {timeout: 2000}
);

Updated on: 28-Jan-2020

97 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements