我想在索引页面中插入一些Jquery代码,根据访问者的地理位置将访问者重定向到以下页面。
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与上述位置不匹配,则只需让访问者留在首页。
答案 0 :(得分: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);
}
});