日期:2014-05-16  浏览次数:20350 次

这个程序有什么问题啊
<html>
<head>
<title>完整的对象定义和使用</title>
<SCRIPT LANGUAGE="JavaScript">
function person(name,age,sex)
{
this.name=name;
this.age=age;
this.sex=sex;

}
bill=new person("bill gate",33,"m");

andy=new person("andy forf",39,"m");
function displaycomputer()
{
var result="一台"+this.year+"年制造的"+this.brand+"计算机,所有者:"+this.owner.name+"<br>";
document.writeln(result);
}
function computer(brand,year,owner)
{
this.brand=brand;
this.year=year;
this.owner=owner;
this.displaycomputer=displaycomputer;
}
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
var Computer1=new computer("microsoft",1999,bill);
var Computer2=new computer("ibm",1994,andy);
computer1.displaycomputer();
computer2.displaycomputer();
</SCRIPT>
</BODY>
</HTML>
------解决方案--------------------
Computer1.displaycomputer();
Computer2.displaycomputer();
注意大小写 你前面是大写的