3

我有www.propertyhere.com

我想在索引页面中插入一些 Jquery 代码,以根据访问者的地理 ip 位置将访问者重定向到以下页面。

 if user ip is from AU then show:
 http://www.propertyhere.com/Country/AU/search-to-buy;

 if user ip is from CA then show:
 http://www.propertyhere.com/Country/CA/search-to-buy;

 if user ip is from NZ then show:
 http://www.propertyhere.com/Country/NZ/search-to-buy;

 if user ip is from US then show:
 http://www.propertyhere.com/Country/US/search-to-buy;

 if user ip is from CN then show:
 http://www.propertyhere.com/Country/CN/search-to-buy;

 if user ip is from RU then show:
 http://www.propertyhere.com/Country/RU/search-to-buy;

如果访问者的 ip 与上述位置不匹配,则让访问者留在主页中。

4

1 回答 1

3

您可以使用诸如http://geoiplookup.wikimedia.org/之类的服务并执行一个简单的 ajax 请求。这应该为您提供所有必要的详细信息。

像这样的圆顶东西可能会有所帮助:

$.ajax('http://geoiplookup.wikimedia.org/', {
    crossDomain:true,
    success:function(data,text,xhqr){
        alert(data);
    },
    error:function(xhr, textStatus){
        alert(xhr.responseText);
    }
});
于 2013-01-30T05:41:04.040 回答