日期:2014-05-17 浏览次数:20645 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <script language="javascript"> function ClassA(color){ this.color = color; this.saycolor = function(){ alert(this.color); }; } function ClassB(color,name){ this.newmethod = ClassA; this.newmethod(color); delete this.newmethod; this.name = name; this.sayhi = function(){ alert(this.name); }; } var obj1 = new classA("red"); var obj2 = new ClassB("blue","as h"); obj1.saycolor(); obj2.saycolor(); obj2.sayhi(); </script> </body> </html>