************************网上的资料*************************************************
2、在子窗体中访问并控制父窗体中对象
在子窗体中我们可以通过其parent即父(双亲)对象来访问父窗口中的对象。
如example.htm:
<html>
<body onclick="alert(tt.myH2.innerHTML)">
<Iframe name="tt" src="frame1.htm" width="250" height="200" scrolling="no"
frameborder="0"></iframe>
<h1 id="myH2">hello,my wife</h1>
</body>
</html>
如果要在frame1.htm中访问ID号为myH2中的标题文字并将之改为"hello,my friend",我们就可以这样写:
parent.myH2.innerText="hello,my friend"
这里parent对象就代表当前窗体(example.htm所在窗体),要在子窗体中访问父窗体中的对象,无一例外都通过parent对象来进行。
*******************************************************************************
问题,在脚本里要写response.write("parent.myH2.innerText='Hollo,my friend'")
这样才行,
我想在frame1.aspx里面直接获取父窗口的myH2的值,然后传给一个变量test,要怎么写代码???
2、在子窗体中访问并控制父窗体中对象
在子窗体中我们可以通过其parent即父(双亲)对象来访问父窗口中的对象。
如example.htm:
<html>
<body onclick="alert(tt.myH2.innerHTML)">
<Iframe name="tt" src="frame1.htm" width="250" height="200" scrolling="no"
frameborder="0"></iframe>
<h1 id="myH2">hello,my wife</h1>
</body>
</html>
如果要在frame1.htm中访问ID号为myH2中的标题文字并将之改为"hello,my friend",我们就可以这样写:
parent.myH2.innerText="hello,my friend"
这里parent对象就代表当前窗体(example.htm所在窗体),要在子窗体中访问父窗体中的对象,无一例外都通过parent对象来进行。
*******************************************************************************
问题,在脚本里要写response.write("parent.myH2.innerText='Hollo,my friend'")
这样才行,
我想在frame1.aspx里面直接获取父窗口的myH2的值,然后传给一个变量test,要怎么写代码???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货