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: 2020-01-28T10:06:05+05:30

175 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements