Call function when user Allows or Denies access to "Physical Location" - Javascript Browser Object Model

Javascript examples for Browser Object Model:Navigator

Description

Call function when user Allows or Denies access to "Physical Location"

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.3.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   w  w w .  j a  v a  2s.c om*/
navigator.geolocation.getCurrentPosition(function(position) {
    console.log('allow');
}, function() {
    console.log('deny');
});
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials