<script language="javascript" defer="defer">
var parent = 
{
    //
    say:function ()
    {
        //
        alert("parent_say");
    },
    alert:function ()
    {
        //
        alert("parent");
        this.say();
    }
};
//


parent.addChild("child",
    {
        //
        say:function ()
        {
            //
            alert("child_say");
        },
        alert:function ()
        {
            //
            alert("child");
            this.parent.say();
        }
    }
);
//parent.child.alert();
//parent.alert();
var c = parent.child;
c.alert();
</script>



<script language="javascript">
Object.prototype.addChild=function(oName, obj)
{
    eval("var p=this."+oName+"= new Object()");
    this[oName]=obj;
    this[oName].parent=this;
}
</script>
效果演示:

[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
标签:
javascript父子通信

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“javascript父子通信”

暂无“javascript父子通信”评论...