html - Geolocation alert won't stay on screen -
i trying implement basic geolocation on web app alert in chrome won't stay on screen; pops @ bottom disappears before can click of options.
you missing error handler function. try adding:
var success = function(position) { //do position }; var failure = function(error) { console.log('error occurred. error code: ' + error.code); // error.code can be: // 0: unknown error // 1: permission denied // 2: position unavailable (error response location provider) // 3: timed out }; navigator.geolocation.getcurrentposition(success, failure);
also, consider adding {timout: 5000}
(or other length of time) 3rd parameter, since function's default timeout search location infinity. see documentation on mdn.
Comments
Post a Comment