【发布时间】:2020-05-05 18:19:59
【问题描述】:
我在 iframe 中显示 AJAX 窗口。我希望用户能够单击并关闭窗口中的关闭按钮。起初这似乎有效,但是当我再次尝试显示窗口时,它就消失了:
function closeme() {
if (parent.document.getElementById ("ifFundingSources")) { // clear the content of iframe if it's there
var iframe = parent.document.getElementById ('ifFundingSources');
iframe.parentNode.removeChild (iframe);
}
}
所以我想我需要隐藏 iframe 而不是删除它?如果是这样,我该怎么做?
编辑:我发现我可以这样隐藏它:
parent.document.getElementById ('ifFundingSources').style.display = "none";
但是,当我下次再次打开窗口时,它仍然是隐藏的。我真正想做的就是用窗口上的按钮关闭窗口。
【问题讨论】: