Discover the location that the user accesses my page [duplicated]

0

I have a domain, www.domain.com and www.domain.com, the content is the same as the difference in the configuration file with the messages that will be loaded.

What is the best technique for finding the location that the user is accessing? so I can set via PHP which configuration file to load.

    
asked by anonymous 17.04.2017 / 22:00

2 answers

1

Use Html5, JavaScript, and Jquery to do geolocation recognition of who accesses your domain. these links should help you: Using geolocation with html5

HTML5 Geolocation API with Javascript

    
17.04.2017 / 22:34
1
  <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> 

  <script type='text/javascript'>//<![CDATA[
   $(window).load(function(){
     $.get("http://ipinfo.io", function (response) {
     $("#ip").html("IP: " + response.ip);
     $("#address").html("Location: " + response.city + ", " + response.region);
     $("#details").html(JSON.stringify(response, null, 4));
     }, "jsonp");
   });//]]> 

  </script>


 <body>

 <div id="ip"></div>
 <div id="address"></div>
 <hr/>Full response: <pre id="details"></pre>
    
17.04.2017 / 22:28