网站首页
高清电影
无损音乐
游戏攻略
电脑教程
破解资源
站长资源
软件下载
javascript父子通信
(编辑:jimmy 日期: 2024/10/14 浏览:
2
)
<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需再刷新一下页面才能执行]
上一篇:
JS获取scrollHeight问题想到的标准问题
下一篇:
如何实现动态删除javascript函数
最新资源
白嘉倩.1992-我有我【星工厂】【WAV+CUE】
黎明.2006-LOOKING【东亚唱片】【WAV+CUE】
群星.1986-国语金曲尽精英【瑞成】【WAV+CUE】
長渕剛《Blood》[FLAC/分轨][299.09MB]
群星《歌手2024 第4期》[320K/MP3][107.39MB]
群星《歌手2024 第4期》[FLAC/分轨][563.76MB]
RiffKitten-ChaosParade(2024)[24-44,1]FLAC
RuneKlakegg-Nattevandrer(2024)[24-96]\FLAC
赖冰霞.2006-金嗓典藏辑2IN1(南方金点系列)2CD【
群星.1988-国语金曲尽精英VOL.2【瑞成】【WAV+C
首页
音乐
电影
资源