Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery how to close dialog from iframe within dialog?

If I open a dialog like so:

$('<iframe id="externalSite" class="externalSite" src="http://www.example.com" />').dialog({
        autoOpen: true,
        width: 800,
        height: 500,
        modal: true,
        resizable: true
    })

How can I close the dialog from withing the iframe?

like image 561
JD Isaacks Avatar asked Aug 26 '10 14:08

JD Isaacks


1 Answers

OK so I put the iframe on the page with display set to none. I open it like this:

$('#externalSite').dialog({ ... });

on the main parent window I have a function like this:

function closeIframe()
{
    $('#externalSite').dialog('close');
    return false;
}

From within the iframe I call:

window.parent.closeIframe();
like image 175
JD Isaacks Avatar answered Oct 19 '22 23:10

JD Isaacks