0

我希望根据访问者的 ip 重定向 url,我有以下代码,经过测试,但它总是去 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>
4

1 回答 1

1

检查您的 if 语句 - 看起来您需要将逗号从 else-if 中取出并替换为分号:

if (mylocation=="AU") {
window.location.href='http://www.propertyhere.com/Country/AU/search-to-buy';
} else if (mylocation=="CA") { ...
于 2013-02-24T14:57:15.760 回答