I have just discovered the code which is redirecting the visitors based on their IP address. For example if we want to redirect our visitors from example.in to example.com as “.in” is our local domain and “.com” is the international domain.
We want our customers to visit international website only who are from US, UK if they visit example.in.
The problem is if they are visting from mobile device, they are not getting redirected. Please help.
Sharing my code below :
<script>
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from Foreign Country
if (location.country_code == 'US' || location.country_code == 'ZA')) {
// Redirect to the International store.
window.top.location.href = 'http://www.example.com';
}
}
} );
</script>
PS : I am placing the above code in example.in
2
Answers
Try this also But I not tried this
Lets do with this http://jsfiddle.net/kvishnudev/7Ut65/1/