【IT168技术文档】
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function Movie(id,name,age)
{
//私有属性
var age=age;
//公有属性
this.ID=id;
this.Name=name;
SayYes=function(words)//私有方法
{
document.write(words);
document.write("Age:"+age);
}
this.ShowInfo=function(words)//公有方法
{
SayYes(words);
document.write("ID: "+this.ID+"|Name: "+this.Name+"<br />");
}
}
Movie.prototype.SayHello=function(words)
{
alert(words);
}
function Animal(sex,age)//基类
{
this.Sex=sex;
this.Age=age;
}
function People(id,name,sex,age)//子类
{
//People.prototype=new Animal();
this.ID=id;
this.Name=name;
this.Sex=sex;
this.Age=age;
this.Say=function()
{
document.write("ID:"+this.ID+"|Name:"+this.Name+"|Sex:"+this.Sex+"|Age:"+this.Age);
}
}
People.prototype=new Animal();
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
var a=new Movie(1,"abc",10);
a.ShowInfo("Yes");
a.SayHello("Hello");
var b=new People(1,"a","男",10);
b.Say();
</script>
</div>
</form>
</body>
</html>