我希望根据访问者的IP重定向网址,并且我有以下代码,经过测试但是它总是要去AU,其他所有其他情况如果条件不起作用,请帮助,非常感谢...
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script language="Javascript">
var mylocation=geoplugin_countryCode();
if (mylocation=="AU") {
window.location.href='http://www.propertyhere.com/Country/AU/search-to-buy'},
else if (mylocation=="CA") {
window.location.href='http://www.propertyhere.com/Country/CA/search-to-buy'},
else if (mylocation=="CN") {
window.location.href='http://www.propertyhere.com/Country/CN/search-to-buy'},
else if (mylocation=="NZ") {
window.location.href='http://www.propertyhere.com/Country/NZ/search-to-buy'},
else if (mylocation=="RU") {
window.location.href='http://www.propertyhere.com/Country/RU/search-to-buy'},
else if (mylocation=="US") {
window.location.href='http://www.propertyhere.com/Country/US/search-to-buy'},
else if {
window.location.href='http://www.propertyhere.com/network'},
</script>
答案 0 :(得分:1)
检查你的if语句 - 看起来你需要从你的else-if中取出逗号并用分号替换:
if (mylocation=="AU") {
window.location.href='http://www.propertyhere.com/Country/AU/search-to-buy';
} else if (mylocation=="CA") { ...