Sunday, May 19, 2024
169
rated 0 times [  174] [ 5]  / answers: 1 / hits: 17432  / 13 Years ago, sun, september 18, 2011, 12:00:00

My application is powered by jQuery mobile and uses geolocation.



After my application attempts to get the user's location, the (Chrome) browser prompts the user:




Example.com wants to track your physical location [allow] [deny]




My goal is:




  1. If the user clicks Allow, function 1 is called (location is used
    by app).

  2. If the user clicks Deny, function 2 is called (address form
    appears).



How can I bind a function to the event that occurs (if any) when the user clicks the Allow or Deny button?


More From » jquery-mobile

 Answers
7

The getCurrentPosition function accepts two function arguments. Heck, the first is executed when you allow and the other when you deny!



Documentation



http://jsfiddle.net/pimvdb/QbRHg/



navigator.geolocation.getCurrentPosition(function(position) {
alert('allow');
}, function() {
alert('deny');
});

[#90035] Friday, September 16, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danalexc

Total Points: 114
Total Questions: 119
Total Answers: 103

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
;