当前位置:IT168首页 > 技术开发 > 概述
[收藏此页] [打印] [推荐] [评论]

javascript 类 继承

责任编辑:nancy作者:ITPUB论坛   2008-05-14   
文本Tag: 微软 sql

【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>
上一页
1
下一页
收藏到: 添加到“百度搜藏”添加到“QQ书签”添加到“Google书签”添加到“Yahoo收藏”添加到“和讯网摘”
【内容导航】
本文欢迎转载,转载请注明:转载自IT168 [ http://www.it168.com/ ]
本文链接:http://tech.it168.com/d/2008-05-14/200805142029015.shtml
技术开发相关文章   .net server SQL 微软
  • 暂无
友情推介