Thursday, April 19, 2012

Call Parent Window Function from Child Window

Parent HTML
function openChild() {
    window.open(url, "child", "width=800,height=180,left=0,top=150,location=0");
    // Syntax - window.open(URL,name,specs,replace)
    // DO NOT leave "name" parameter blank. In this case it is "child"
)

function parentMethod() {
    alert("Hello From Parent");
}

Child HTML

function  callParentMethod (customerKey, programKey) {
    window.opener.parentMethod ();
}


<input type="button" id="btn" onclick="callParentMethod()" value="Call Parent Method">


Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home