<h:commandButton value="Press me to bring up a popup window" onclick="window.open('popup.jsp', 'popup_window')" />
This exact method won't work with a commandLink, because this does not offer an onclick option. However the mouseup event can be used instead:
<h:commandLink onclick="window.open('popup.jsp', 'popup_window')">
Press me to bring up a popup window
</h:commanndLink>
Of course, both commandButton and commandLink items need to be enclosed in a form element. This means that the form will be submitted when the commandButton or commandLink is pressed/clicked. In order to avoid it, we have to return false from within the onclick or mouseup attribute.
Press me to bring up a popup window
</h:commanndLink>
<h:commandButton value="Press me to bring up a popup window" onclick="window.open('popup.jsp', 'popup_window'); return false;" />
No comments:
Post a Comment