日期:2014-05-18  浏览次数:20636 次

怎么提示abc是未定义对象
<html>
    <head>
      <title>
      information
      </title>
    </head>


<script   language=JavaScript>
function   show()
{
    window.alert( "this.info ");

}

function   myInformation(a,b,c)
{   this.pro=a;
    this.city=b;
    this.road=c;
    this.info= "地址是 "+this.pro+this.city+this.road;
    this.show=show;
}

var   abc=new   myInformation( "安徽省 ", "合肥市 ", "人民路 ");

</script>
<body>

<form>
<input   type= "button "   value= "我的地址显示 "   onclick=abc.show() ">
</form>

</body>
</html>


------解决方案--------------------
函数的参数不用定义参数类型吗?
------解决方案--------------------
<html>
<head>
<title>
information
</title>
</head>


<script language=JavaScript>
function show()
{
window.alert(this.info); //为什么要加引号?

}

function myInformation(a,b,c)
{ this.pro=a;
this.city=b;
this.road=c;
this.info= "地址是 "+this.pro+this.city+this.road;
this.show=show;
}

var abc=new myInformation( "安徽省 ", "合肥市 ", "人民路 "); //发现中文逗号

</script>
<body>

<form>
<input type= "button " value= "我的地址显示 " onclick= "abc.show() "> //少了一个双引号,
</form>

</body>
</html>


------解决方案--------------------
如果是null就是未定以