简体   繁体   English

如何从包含aspx页面按钮的iframe关闭父级弹出窗口?

[英]How to Close Parent Popup from Iframe containing aspx page button?

I have one popup which contain iframe and inside iframe i called .aspx page . 我有一个弹出窗口,其中包含iframe和称为.aspx页面的iframe内部。 So how I can close parent popup from .aspx close button . 因此,如何从.aspx关闭按钮关闭父级弹出窗口。 I'm not using AjaxModalPopup . 我没有使用AjaxModalPopup

I tried $('#formModal', window.parent.document).hide(); 我试过$('#formModal', window.parent.document).hide(); it just hide the popup but does not allow to click on the parent page. 它只是隐藏弹出窗口,但不允许单击父页面。

I am using magnificPopup and it also using iframe. 我正在使用magnificPopup,它也在使用iframe。 Below is my code, 下面是我的代码,

 if (typeof parent.$.magnificPopup != 'undefined') {
            parent.$.magnificPopup.close();
        }

On the .aspx page in the iframe you can use this: 在iframe的.aspx页上,您可以使用以下命令:

<span onclick="parent.ClosePopup('send optional variable')">Close this popup</span>

And on the page with the iframe just a normal javascript function. 在带有iframe的页面上,只是一个普通的javascript函数。

function ClosePopup(msg) {
    alert(msg);
    //code to close the popup
}

This only works with pages on the same domain, see https://en.wikipedia.org/wiki/Same-origin_policy 这仅适用于同一域中的页面,请参阅https://en.wikipedia.org/wiki/Same-origin_policy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM