js父子通讯
1.js脚本
var Parent=
{
//
say:function ()
{
//
alert("parent_say");
},
alert:function ()
{
//
alert("parent");
this.say();
}
};
//
Parent.Child={
//
say:function ()
{
//
alert("child_say");
},
alert:function ()
{
//
alert("child");
this.parent.say();
}
};
2.添加父子关系
Object.prototype.addChild=function(oName, obj)
{
eval("var p=this."+oName+"= new Object()");
this[oName]=obj;
this[oName].parent=this;
};
Vicson.addChild("VMS",Vicson.VMS);
3.调用示例
//Parent.Child.alert();
//Parent.alert();
var c = Parent.Child;
c.parent.alert();
js父子通讯
最新推荐文章于 2023-05-17 18:39:54 发布