zoukankan      html  css  js  c++  java
  • Iframe之间及iframe与父窗体之间值的传递

    方法一:ScriptManager.RegisterClientScriptBlock(this,typeof(Page), "NoInformation", "window.parent.frames['Add'].location.reload();", true);     此: 会弹出页面刷新错误
    方法二: ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "NoInformation", "window.parent.frames['Add'].location.href='DepartAdd.aspx';", true);     最好的方法 可解决跳转刷新后窗体样式的改变。

     

     

    参考:

    (一)父窗体调用iframe子窗体的例子:
    1
    //将子iframe中text的值赋给父窗体中一个text
    document.getElementById('applyDate').value=window.frames["capitalList"].document.all('applytime').value;
    2
    //父窗体中的一个按钮onclick触发子iframe中form的button1服务器端事件
    window.frames(capitallist).document.forms.item(0).button1.click();或写作:
    window.frames(capitallist).document.form1.button1.click();
    注:我测试上面两个写法不好用不知啥原因
    但是使用下面的方法可以
     function regedit()
            {
                  document.frames["iframe1"].document.getElementById("tb_name").value=document.getElementById("TextBox1").value;
                 document.frames["iframe1"].document.getElementById("tb_pwd").value=document.getElementById("TextBox2").value;
                document.frames["iframe1"].document.getElementById("btn_zc").click();
                //frame.document.getElementById("btn_zc").onclick();
    }
     <input type="button" value="注册" id="btn_reg" onclick="regedit()" />
    (二)iframe子窗体调用父窗体的例子:
    1
    //子iframe中的form的button的onclick事件给父窗体的一个text赋值
    window.parent.document.all('applyDate').value=document.getElementById('applytime').value;
    2
    //子页面调用父窗体的某个按钮的按钮事件
    window.parent.form1.button1.click()
    (三)iframe子窗体之间相互调用
    //右边iframe中页面的按钮调用左边的iframe中的页面,让左边页面得以刷新

    parent.frame(menu).window.location.reload();

    请看下面简单例子,不多解释. 
    父窗体:test.htm 
     1 <span style="font-size: small;"><span style="color: #000000;"><HTML>   
     2 <HEAD>   
     3 <TITLE> Test Page </TITLE>   
     4 <script src="prototype-1.4.0.js"></script>   
     5 <script language="javascript">   
     6 function show(){   
     7   //改变iframe中的元素id为myH1的内容  
     8         window.frames["iframe_text"].document.getElementById("myH1").innerHTML = "http://www.pint.com";   
     9 }   
    10 </script>   
    11 </HEAD>   
    12 <BODY>   
    13 <iframe height="350"  width="600" src="iframe_text.htm"   
    14 name="iframe_text"></iframe>   
    15 <form action="" method="post">   
    16 <input name="haha" id="haha" type="text" maxlength="30" value="haha"   
    17 /><br />   
    18 <textarea cols="50" rows="5" id="getAttributeMethod"></textarea>   
    19 <input type="button" onClick="show();" value="提交"/>   
    20 </form>   
    21 <h2 id="myH2">d</h2>   
    22 </BODY>   
    23 </HTML></span></span><br><span style="font-size: small;"><span style="color: #000000;">iframe的页面内容: <br></span></span>  


     2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
     3 <html xmlns="http://www.w3.org/1999/xhtml">   
     4 <head>   
     5 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />   
     6 <title>无标题文档</title>   
     7 </head>   
     8 <script language="javascript">   
     9 function show(){   
    10   //改变父窗体中的元素id为myH2的内容  
    11         parent.document.getElementById("myH2").innerHTML =   
    12 "http://www.adsf.com";   
    13   
    14 }   
    15   
    16 </script>   
    17 <body>   
    18 <h1 id="myH1">ha</h1>   
    19 <form action="" method="post">   
    20 <input name="abc" id="abc" type="text" maxlength="30" value="abc" /><br   
    21 />   
    22 <textarea cols="50" rows="10" id="text"></textarea> <br />   
    23 <input type="button" value="提交" onclick="show();"/>   
    24 </form>   
    25 </body>   
    26 </html></span></span>  
  • 相关阅读:
    [leedcode 77] Combinations
    [leedcode 76] Minimum Window Substring
    [leedcode 75] Sort Colors
    [leedcode 74] Search a 2D Matrix
    [leedcode 73] Set Matrix Zeroes
    [leedcode 71] Simplify Path
    [leedcode 70] Climbing Stairs
    [leedcode 69] Sqrt(x)
    [leedcode 67] Add Binary
    HDU1027-Ignatius and the Princess II(全排列问题next_permutation函数的使用)
  • 原文地址:https://www.cnblogs.com/tianma3798/p/3491728.html
Copyright © 2011-2022 走看看