日期:2014-05-17  浏览次数:20899 次

JScript 得到IP的函数,有错吗?
function   GetIp(){
var   realip   =   new   String(Request.ServerVariables( "HTTP_X_FORWARDED_FOR "));
var   proxy   =   new   String(Request.ServerVariables( "REMOTE_ADDR "));

if(realip.length> 0){
return   realip;
}
else{
        return   proxy;
}
}

不知道哪错了.....求高手

------解决方案--------------------
function GetIp(){
var realip = " ";
realip = new String(Request.ServerVariables( "HTTP_X_FORWARDED_FOR "));
var proxy = new String(Request.ServerVariables( "REMOTE_ADDR "));

if(proxy.length==0){
return realip;
}
else{
return proxy;
}
}