我想要這樣的東西。如何在p:對話框中打開url?
<h:commandButton value="Submit" onclick="ex.show()"></h:commandButton>
<p:dialog id="dialog1" widgetVar="ex">
<h:output Text value="Hi"/>
</p:dialog>
這會在p:對話框中打開hi文本彈出窗口。但我需要在該彈出窗口中打開一個網址。我怎麼接近?
我想要這樣的東西。如何在p:對話框中打開url?
<h:commandButton value="Submit" onclick="ex.show()"></h:commandButton>
<p:dialog id="dialog1" widgetVar="ex">
<h:output Text value="Hi"/>
</p:dialog>
這會在p:對話框中打開hi文本彈出窗口。但我需要在該彈出窗口中打開一個網址。我怎麼接近?
您可以將iframe
裏面你的對話框
像這樣:
<h:form prependId="false">
<h:commandButton value="Submit" onclick="ex.show(); return false;"></h:commandButton>
<p:dialog id="dialog1" widgetVar="ex" onHide="jQuery('#someId').hide();" onShow="jQuery('#someId').show();">
<iframe frameborder="0" align="left"
src="http://www.primefaces.org"
name="someName" id="someId" scrolling="auto" width="750"
height="500" marginheight="5" marginwidth="10">
</iframe>
</p:dialog>
</h:form>
第二個選項,可以將p:lightBox iframe="true"
你的對話框內,並打開它時,被打開的對話框中,像這樣:
<h:form prependId="false">
<h:commandButton value="Submit" onclick="ex.show(); return false;"></h:commandButton>
<p:dialog id="dialog1" widgetVar="ex" onShow="openLink()">
<p:lightBox iframe="true">
<h:outputLink id="mylink" value="http://www.primefaces.org">
</h:outputLink>
</p:lightBox>
</p:dialog>
<script>
function openLink(){
setTimeout("jQuery('#mylink').click();", 50);
}
</script>
</h:form>
由於Daniel..It工程.... – user1788115
但iframe打開後,如果您在該iframe之外單擊,則會消失,並顯示p:對話框。如何克服它? – user1788115
@ user1788115是否發生在我的第一個解決方案上?因爲第一個對我來說工作得很好,如果它適合你,你應該將答案標記爲已接受... – Daniel
我的代碼沒有出現,所以我發佈在我的代碼下面: 小時:的commandButton>
的 –
user1788115