How do I know when a user cancels HTML5 geolocation?

Sometimes I would like to know if the user wants to share his location. Is there an event that is triggered when a pop-up shared location closes without sharing?

PS: The error callback is not called when the user does not share his location.

+4
source share
2 answers

This question answers the same question: Sending geolocation when accepting request

I copied part of the code below, but check the page, as there is an example of how to process them, not accept or reject, but ignore the timeout request.

// navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options); navigator.geolocation.getCurrentPosition( function(position){ //do something with position; }, function(error){ // error passed to function //handle condition where position is not available //more specifically you can check the error code... //error.code == 1 if(error.PERMISSION_DENIED){ alert("you denied me! "); } }); 
+3
source

Reading this article will provide you with good guidance on what you are asking. http://diveintohtml5.ep.io/geolocation.html

and

http://diveintohtml5.ep.io/detect.html#geolocation

0
source

All Articles