【问题标题】:Passing a string from JavaScript of popup window to parent window将字符串从弹出窗口的 JavaScript 传递到父窗口
【发布时间】:2013-03-05 07:02:11
【问题描述】:

我有一个看起来像这样的 JavaScript 函数。我需要帮助将这些值从弹出窗口的 JavaScript 传递到父窗口。我知道我必须使用

window.opener.document.getelementbyD("ID Of TextBox");

我的子 aspx 页面中的方法,但 textbox 在另一个用户控件中。我该怎么做?

function(PersonName, EmailID){
    //assign these values to text boxes of  a parent window 
    //the text boxes of parent window are inside of  control
}

问候
-毗湿奴

【问题讨论】:

标签: javascript asp.net


【解决方案1】:

你可以编写两个普通的 JS 函数。您的“父”窗口中的一个(setValues)将由您的弹出窗口调用。并且在您的弹出窗口 (setValuesToParent) 中收集值并在您的父窗口中调用函数。请不要忘记,这个例子是用纯 JavaScript 编写的,不使用任何 asp.net 的东西。

// in your pop up 
function setValuesToParent() {
    var PersonName= document.getElementById('PersonNameInPopUp').value;
    var EmailID = document.getElementById('EmailIDInPopUp').value;
    window.opener.setValues(PersonName, EmailID); // this is the important line
}



// in your parent window
function setValues(PersonName, EmailID) {
    document.getElementById('PersonName').value = PersonName;
    document.getElementById('EmailID').value = EmailID;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-22
    相关资源
    最近更新 更多