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));
}