GetCookie("username");//下面这段代码是获取cookie的
function GetCookie(CookieName)
{
var strCookie=document.cookie;
if(strCookie==null || strCookie=="")//如果没有cookie对象,则显示默认状态,即未登录状态,并返回false。
{
document.getElementById("showContent").innerHTML=nologin_str;
}
else//如果有cookie对象,找出所有的cookie。
{
var arrCookie=strCookie.split(";");
for(var i=0;i<arrCookie.length;i++)
{
var arr=arrCookie[i].split("=");
//alert(arr[0]+"----"+arr[1]+"----"+typeof(arr[0])+"----"+typeof(arr[1]));
if(arr[0]==CookieName)//判断是否有所需的cookie的名字。
{
if(arr[1]==null || arr[1]=="")
{
document.getElementById("showContent").innerHTML=nologin_str;
}
else
{
document.getElementById("showContent").innerHTML=login_str.replace("{$login_content_string}",arr[1]);
break;
}
}
else
{
//alert(arr[0]+"----"+arr[1]+"----"+CookieName+"----"+typeof(arr[0])+"----"+typeof(arr[1]));
document.getElementById("showContent").innerHTML=nologin_str;
}
}
}
}if(arr[0]==CookieName)就这里arr[0]跟CookieName他们的值是相等的,而且类型也是一样的,但是为什么就是不成立呢?