javascript父子通信
2007-05-27 00:00
183 查看
<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>
效果演示:
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();
Object.prototype.addChild=function(oName, obj)
{
eval("var p=this."+oName+"= new Object()");
this[oName]=obj;
this[oName].parent=this;
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
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>
效果演示:
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();
Object.prototype.addChild=function(oName, obj)
{
eval("var p=this."+oName+"= new Object()");
this[oName]=obj;
this[oName].parent=this;
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
相关文章推荐
- JavaScript实现父子两个窗口之间互相通信
- JavaScript实现父子两个窗口之间互相通信
- JavaScript:父子页面(iframe)之间通信实例
- 【JavaScript】父子页面之间跨域通信的方法
- javascript父子通信
- UIWebView 中JavaScript 与 Objective-C 通信
- 父子页面之间跨域通信的方法
- Vue2.0 父子组件之间通信
- React中父子组件间的通信问题
- React兄弟、父子元素之前的通信
- vue2.0父子组件以及非父子组件如何通信
- vue2.0父子组件以及非父子组件通信
- 父子进程通信的两种方式--消息队列和共享内存
- JavaScript/jQuery、HTML、CSS 构建 Web IM 远程及时聊天通信程序
- vue实现父子双向通信
- javascript事件之:jQuery事件中实例对象和拓展对象之间的通信
- 常见的javascript跨域通信方法
- Javascript常见问题及解决(二)如何实现浏览器内多个标签页之间的通信?
- React中父子组件间的通信问题
- Linux c==使用父子进程实现TCP通信(15)