• 通过js子页面回写父页面,改变父页面控件的值


    [原]js中实现子页面向父页面中赋值

    (方法一)

    父页面:
    <input  id="input1" type="text"/>
    <a href="javascript:window.open('test1.aspx');void(0)">弹出新的子窗口</a>

    子页面:
    <input id="input2" type="text" />
    <input id="bt" type="button" onclick="doit();" value="更新父窗口的内容"/>
    <script type="text/javascript" language="javascript">
    function doit()
    {
      var _value=document.getElementByIdx('input2').value;
      window.opener.document.getElementByIdx('input1').value=_value;
    }
    </script>

    (方法二)

    父页面:
    <input id="input1" type="text" />
    <a href="javascript:GetReturnValue();void(0)">弹出新的模态子窗口</a>
    <script type="text/javascript" language="javascript">
     function GetReturnValue()
     {
         var temp= window.showModalDialog("test1.aspx","","center=yes;help=no;status=no");
         document.getElementByIdx('input1').value = temp;
     }
    </script>

    子页面:
    <input id="input2" type="text" />
    <input id="bt" type="button" onclick="doit();"  value="更新父窗口的内容"/>
    <script type="text/javascript" language="javascript">
    function doit()
    {
      var _value=document.getElementByIdx('input2').value;
      window.returnValue =_value;
      window.close();
    }
    </script>

  • 相关阅读:
    置换笔记
    7.23
    Conveyor Belts
    CF #134 A~D
    Blocks && Fixing the Great wall
    Kakuro
    Deadlock Detection
    关于KeyFile的破解,含注册机源代码
    BMP位图之代码实现
    BMP位图之8位位图(三)
  • 原文地址:https://www.cnblogs.com/Mr-Rocker/p/3573826.html
Copyright © 2020-2023  润新知