框架网页 top left main, 从main frame 中访问 top中的元素怎么办?

来源:百度知道 编辑:UC知道 时间:2024/07/05 02:20:47
在top中,<input type="text" value="abc" id="abc">

在main中有一个按纽<input type="button" onclick="changeValue();">

<script>
function changeValue(){
怎么样写js改变top中文本框的值
}
</script>

分别列出三个文件的内容如下:

(1) frame.html
<frameset rows="30%, 70%">
<frame name="topframe" src="top.html">
<frameset cols="40%, 60%">
<frame src="left.html">
<frame src="main.html">
</frameset>
</frameset>

(2) top.html
<input type="text" value="abc" id="abc">

(3) main.html
<input type="button" onclick="changeValue();">

<script>
function changeValue(){
parent.topframe.abc.value='I have be changed!!!';
}
</script>

分别列出三个文件的内容如下:

(1) frame.html
<frameset rows="30%, 70%">
<frame name="topframe" src="top.html">
<frameset cols="40%, 60%">
<frame src="left.html">
<f