index.html:
<html>
<body>
<div>
<iframe id="a" stc=a.html>
</iframe>
</div>
</body>
</html>
a.html:
<html>
<frameset>
<frame src="aa.html" id="aa">
<frame src="bb.html" id="bb">
</frameset>
</html>aa.html:
<html>
<body>
<div>
<input id="aaa" name="aaa" value="" type="text">
</div>
</body>
</html>
通过document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value 可以获取aa.html页面上的值传到到index.html上。
现在的要求是从index.html 的JS里定义一个常量,赋值给aa.html的value值。
 

解决方案 »

  1.   

    不知道你这三个页面是什么关系啊  是点击一个页面弹出另一个页面么?如果是的话可以用
    window.opener.document.getgetElementById("a").value = '';的方式来赋值
    如果是弹出的第n个页面的话,那么可以写n个 opener 
      

  2.   

    不明白你想问什么既然知道在index.html中通过
    document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value 
    可以取到aa.html的value值。那么只要
    document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value  = "bbb";就可以实现赋值了。下面是我做的测试代码,
    function test() {
         var obj = document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa");
         obj.value = "bbb";
    }
    实现了在index.html中调用这个方法就可以将aa.html中的aaa文本框的值赋为“bbb”。
      

  3.   


    document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value ="";不行??
      

  4.   

    简单来说 就是 我要在index写JS代码实现 把值从index.html传给aa.html的。
    document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value 这个过程是从aa.html到index.html的  就是一个来一个回得问题。我现在只知道怎么把值从aa.html中要过来,但是不知道怎么把值给它
      

  5.   

    document.getElementById("a").contentWindow.document.getElementById("aa").contentWindow.document.getElementById("aaa").value="";//赋值
    你在获取下,看看是不是想吻合....
    难道不行???