页面A,为父页面
调用 GetDate()方法打开pop.html
function GetDate(){
window.showModalDialog("pop.html", '',"status:no;center:yes;scroll:no;resizable:no;help:no;dialogWidth:300px;dialogHeight:310px");
}在pop.html里面,有个iframe,调用到sub_pop.html
<body style="overflow-x:hidden;overflow-y:hidden">
<iFrame src="sub_pop.html"   border=0  frameborder=0 height=100% style="overflow-x:hidden;overflow-y:hidden" />
 </body> 在sub_pop.html 中有个按钮事件,请问
在这个iframe里面如何给父页面A中的某个text控件赋值???

解决方案 »

  1.   

    a.html<html>
    <script type="text/javascript">
        function GetDate(){
            var a_text = document.getElementById("a_text");
        window.showModalDialog("pop.html", a_text, "status:no;center:yes;scroll:no;resizable:no;help:no;dialogWidth:300px;dialogHeight:310px");
        }
    </script>
    <body>
    <input type="text" id="a_text"/>
    <input type="button" onclick="GetDate()" value="getDate"/>
    </body>
    </html>pop.html<html>
    <body>
    <iframe src="sub_pop.html">
    </iframe>
    </body>
    </html>
    sub_pop.html<html>
    <script type="text/javascript">
    function setAValue(){
    parent.window.dialogArguments.value="好了,给分吧!";
    }
    </script>
    <body>
    <input type="button" onclick="setAValue()" value="设值"/>
    </body>
    </html>
      

  2.   

    再顺便问最后一格问题,如果换成window.open弹出,改怎么些对应的代码呢?马上实验,马上给分!!
      

  3.   

    window.open 弹出的窗口1
    1、获取父窗口的引用
    2、返回字符串给父窗口
      

  4.   

    拜托给点sample,如3楼那样
    javascript基本上不会
      

  5.   

    a.html
    <html>
    <script type="text/javascript">
        function GetDate(){
            var a_text = document.getElementById("a_text");        
            window.open("pop.html");
        }
    </script>
    <body>
        <input type="text" id="a_text"/>
        <input type="button" onclick="GetDate()" value="getDate"/>
    </body>
    </html>sub_pop.html<html>
    <script type="text/javascript">
        function setAValue(){
            var openDoc = parent.opener.document;
            openDoc.getElementById("a_text").value="结贴了!";
        }
    </script>
    <body>    
        <input type="button" onclick="setAValue()" value="设值"/>
    </body>
    </html>
      

  6.   


    前辈你好 我也遇到了这个问题 parent.window.dialogArguments.value? 谁的value? 
    如果我只是想单独的给父窗口的某一个控件赋值呢? 
    比如我给父窗口的<input type="text" id="name" name="name" />赋值怎么办? 
      

  7.   

     jQuery(":checked").each(function(q,i){
    var codeid=jQuery(i).parent().parent().find("td").eq(1).html();
    codeid=codeid.substring(0,codeid.length-1);
    var codename=jQuery(i).parent().parent().find("td").eq(2).html();
    codename=codename.substring(0,codename.length-1);
    window.opener.jQuery("#tbb tr").find("input[name=codename][value='']").each(function(n,b){
    jQuery(b).parent().parent().find("input").eq(1).val(codeid);
    jQuery(b).parent().parent().find("input").eq(2).val(codename);
    return false;
    });
    });   这是子窗体操作父窗体 子窗体值给父窗体