2

I am trying to figure out an alternative way of getting a user's location when your browser (firefox, chrome, etc) blocks geolocation and I wanted to call an API to get the user's location based on their IP address. However, I can't figure out how to do this. It seems that my function to handle errors does not pick up the browser blocking geolocation. What can I do? I have just started learning HTML5 and Javascript. Here is an example of my code:

     function getUserLoc() {
        if (navigator.geolocation) {
           navigator.geolocation.getCurrentPosition(showPosition,noGeo,geo_options);
        } else {
           noGeo();
        }
     }

     function showPosition(position) {
        loc = position.coords.latitude,position.coords.longitude;

     }

     function noGeo(error) {
        <!-- Here I would insert the code to get the location via the user's IP address -->
     }

0 Answers0