隐藏框架 传值

来源:百度知道 编辑:UC知道 时间:2024/09/23 15:32:41
我想做一个无刷新的页面.
一个main网页上包含两个子框架,一上一下.
上面的框架取名top,下面的取名down.
上面的(top)框架上有三个本文本框.toptext1; toptext2; toptext3
下面的框架(down)上有三个本文框框和三个按钮.
downtext1;downtext2;downtext3;
button1;button2;button3;
要求实现以下功能:
在downtext1中输入文字后,然后按button1. 此时downtext1中的文字就在toptext1中显示.
接着在downtext2中输入文字后,然后按button2. 此时downtext2中的文字就在toptext2中显示.注意此时top并不刷新.toptext1中的文字仍然存在.(如果刷新了toptext1中的内容也是丢了.)
接着在downtext3中输入内容,然后按button3. 此时downtext3中的文字就在toptext3中显示.注意此时top并不刷新.toptext1和toptext2中的文字仍然存在.
我查了一下资料,都说用ajax或隐藏框架可以搞定,ajax就不要介绍了,我能实现,但太麻烦.我只求利用隐藏框架 传值的方法.赏分10分.

frame传参不用ajax的

//index.html

<style>
a {
display:block;
margin-bottom:20px;
width:30px;
}
iframe {
width:400px;
height:300px;
border:1px solid #000;
}

</style>
<script>
window.onload=function(){
document.getElementById('x').onclick=function(){
frames['_left'].document.getElementById('a').innerHTML=frames['_right'].document.getElementById('b').value.replace(/

\n/g,'<br />');
}

}
</script>
<a href="#" id="x">点</a>

<iframe name="_left" src="1.html"></iframe>
<iframe name="_right" src="2.html"></iframe>

//1.html
<div id="a" style="background:#000;color:#fff;width:300px;height:400px;"></div&