gpt4 book ai didi

jquery - 从 iFrame 关闭 primefaces 对话框

转载 作者:行者123 更新时间:2023-12-01 03:45:08 26 4
gpt4 key购买 nike

我想在一个页面上显示一个对话框。

代码:

page1.xhtml

<p:commandLink value="Show Dialog" oncomplete="dlgWVar.show();"/>
<p:dialog widgetVar="dlgWVar"
width="800"
id="dialog"
position="top"
modal="true"
header="Test Dialog"
height="500">

<iframe src="page2.xhtml" width="100%" height="500px" style="border-width: 0PX;">
</iframe>

</p:dialog>

现在,在此对话框中,我有 iFrame,其中链接了 page2.xhtml。

page2.xhtml

   <p:commandButton value ="Close Dialog">
</p:commandButton>

page2.xhtml 包含一个命令按钮。现在我必须在单击命令按钮后关闭对话框。

不知道该怎么做。我应该在 page2.xhtml 上的 commandButton 中写什么,以便关闭 page1.xhtml 上的对话框。请帮忙。

谢谢。

最佳答案

对于较旧的 PrimeFaces 版本,请尝试使用 window.parent.dlgWVar.hide()。仅当主窗口和 iframe 都显示来自同一域的页面时,这才有可能。

对于 PrimeFaces 5 及更高版本,请参阅其他答案

关于jquery - 从 iFrame 关闭 primefaces 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14332925/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com