<script>
function setErrorNumber(num)
{
this.number=num;//这里这么写
switch(this.number)
{
case 0:this.brief="Session is empty.";break;
case 1:this.brief="数据库中没有您的信息。";break;
case 2:this.brief="您的密码与用户名不匹选。";break;
default:this.brief="未知的错误。";
}
}
function getErrorNumber(mybool)//得到对象中的this.number的值
{
if(mybool)
return this.number;//这里这么写
else
return this.brief;
}
function UserError()
{
//Methods
this.setErrorNumber(2);
//this.setErrorNumber(3);
this.number=this.getErrorNumber(true);
this.brief=this.getErrorNumber(false);
//Properties
alert(this.number);
alert(this.brief);
}
UserError();
</script>

解决方案 »

  1.   

    <script>
    function setErrorNumber(num)
    {
    this.number=num;//这里这么写
    switch(this.number)
    {
    case 0:this.brief="Session is empty.";break;
    case 1:this.brief="数据库中没有您的信息。";break;
    case 2:this.brief="您的密码与用户名不匹选。";break;
    default:this.brief="未知的错误。";
    }
    }
    function getErrorNumber()//得到对象中的this.number的值
    {
    return this.number;//这里这么写
    }function getErrorBrief()//得到对象中的this.brief的值
    {
    return this.brief;//这里这么写
    }
    function UserError()
    {
    //Methods
    this.setErrorNumber=setErrorNumber;
    this.getErrorNumber=getErrorNumber;
    this.getErrorBrief=getErrorBrief;
    //Properties
    this.number=0;
    this.brief="";
    }var t=new UserError();
    t.setErrorNumber(1)
    alert(t.getErrorNumber()+":"+t.getErrorBrief())
    </script>