jquery - Determine user location then redirect to different home page -


i want able change image depending on location user has viewed site from? or alternatively navigate them page.

ideally pick using jquery, i'm not 100% sure if effective.

for example, want swap in different image if user visiting site london. can region specific?

thanks gillian


just got work of beda0805

here's solution

<!doctype html> <html> <head>   <meta http-equiv="content-type" content="text/html; charset=utf-8">   <title>location</title>   <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) {      if(response.region == 'london'){        $("#address").append("<p>your in london</p>");      }      if(response.region != 'london'){        $("#address").append("<p>your anywhere else</p>");      }     }, "jsonp");  </script> </head> <body>   <div id="address"></div> </body> </html> 

here nice tutorial.

you use check if user london:

google.loader.clientlocation.address.city == 'london'  

and use javascript insert picture div id="yourinfo".

elem.src = 'images/london.jpg'; document.getelementbyid("yourinfo").appendchild("elem"); 

update:

above api seems out of date. working solution here: jsfiddle ben dowling


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -