I am using the getCurrentPosition method in Javascript. I would like to implement a button that stops the "getCurrentPosition" method when clicked. I tried using throw / try / catch blocks, but it does not work:
try {
$ ('# cancel'). on ("click", function () {
$ .mobile.loading ('hide');
throw "stop";
});
navigator.geolocation.getCurrentPosition (foundLocation, noLocation, {enableHighAccuracy: true, timeout: 30000});
}
catch (er) {alert (er); return false; }
Any ideas? Is this possible in JS? I had an idea, but I don’t know if it is possible to start a timeout using the JS method to getCurrentPosition break?
Laila source
share