开发者

How to close a jquery UI dialog with iframe

开发者 https://www.devze.com 2023-01-21 03:53 出处:网络
Here is how I initialize the dialog: $(\'a.dialog\').click(function(e) { e.preventDefault(); var开发者_如何学Python $this = $(this);

Here is how I initialize the dialog:

$('a.dialog').click(function(e) {
    e.preventDefault();
    var开发者_如何学Python $this = $(this);
    $('<iframe id="externalSite" class="externalSite" src="/controller/action" frameBorder="0"></iframe>').dialog({
        modal: true,
        resizable: false,
        title: 'Title',
        zIndex: 1,
        show: 'fast',
        hide: 'slow',
        width: 600,
        height: 400,
        position: 'middle'
    }).width(600);
});

How can I close it from inside the iframe?

For example, I'd like to have a link inside the iframe that will close the dialog.


You can use window.parent or window.top to reference parent window. Starting from there, you should be able to find your dialog with jquery and close it. Something like

$(window.top.document).find('#externalSite').dialog('close');

https://developer.mozilla.org/en/DOM/window.parent

0

精彩评论

暂无评论...
验证码 换一张
取 消