Find out where the user accesses my page

Asked

Viewed 1,753 times

0

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

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

2 answers

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>

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.