【问题标题】:Waiting values from child window来自子窗口的等待值
【发布时间】:2012-02-28 16:07:07
【问题描述】:

<Asp:Button ID=... onclick="openChildWindow()"

<asp:label ID="label1"  ....>

我有一个包含按钮和标签的网页。当我点击按钮时, openCHildWindow() 执行:

openChildWindow()
{ //open child window...
//some other functions....
}

在子窗口中,有一个文本框,我可以在其中输入一些内容。 我的问题是:如果我需要子窗口将文本框中的值传输到父窗口,是否可以 //some other functions 等到父窗口从子窗口获取值?

谢谢。

【问题讨论】:

    标签: javascript asp.net


    【解决方案1】:

    我不确定您是否可以让父窗口“等待”子窗口,或者您是否愿意,因为您很可能会收到“长时间运行的脚本”消息,但我知道您可以访问子窗口的父窗口使用

    window.opener

    所以您应该能够在关闭子窗口之前执行以下操作:

    window.opener.document.getElementById('text1').value = myTextboxValue;
    window.close();
    

    也许更好的是在父窗口中调用一个函数:

    window.opener.ParentWindowFunction(myTextboxValue);
    window.close();
    

    尝试浏览这篇文章:

    http://www.codeproject.com/Articles/25388/Accessing-parent-window-from-child-window-or-vice

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多