vijayp
vijayp

Reputation: 173

Pass variable from child window to parent window between 2 applications

I have opened a child window using a showModal dialog where the URL points to a different website as the main window does.

I want to pass some variables from the child window to the parent window using the script below.

Script used in Parent window:

function Open() {
    var Return;
    Return = window.showModalDialog("https://example.com/ChildApp/ChildForm.aspx", "", "dialogWidth:670px;dialogHeight:600px;")
    alert(Return.passVariable);
}

The URL for the parent window is something like this: https://example.com/MainApp/MainForm.aspx

Script used in Child window:

function Close(parameter) {
    var vReturnValue = new Object();
    vReturnValue.passVariable= parameter;
    window.returnValue = vReturnValue;
    window.close();
} 

In the main window, Return returns null.

One more issue exists when I'm trying to get a reference of window.parent, it gives a null value in the child window.

Note: Here ChildApp and MainApp are two different applications.

Upvotes: 0

Views: 638

Answers (0)

Related Questions