js null ,null没有typeof返回值为undefine 即 null没有返回类型的

var user="<%=session.getAttribute("username")%>";
alert(user);
alert(user.length);
if(null !=user)
{
alert("请先登录!");
return false;
}
else
{
return (count(document.bookbuy.bookcount.value));
}

我测试了下,如果写成是 if(null.length==4),即是好使的,请问下为什么null 的length 是 4?
  其实是把var  user="null";了,所有length 值为4,一楼回答的有一定道理。
可以这样修改
方法:
 if('null' != user)

{

    
    alert("请先登录!");

   
    return false;

  
  }

else

{

  
    return (count(document.bookbuy.bookcount.value));
}

posted @ 2013-05-30 13:22  Struts-pring  阅读(432)  评论(0编辑  收藏  举报