I have a pop-up window (div) displayed when I click on outPutLink by calling a javascript function

<apex:outputLink value="javascript:pop();" id="pl" disabled="false">pop</apex:outputLink>

when the div appears, it is includes a commandButton that close the popup div using javascript function too.

<apex:commandButton id="plClose" value="Close" onclick="javascript:hidePop();" />

but when I click on close, the whole page reloaded.

this is the js block

  var $j = jQuery.noConflict();


  function hidePop(){

  function pop(){

  • 1
    onclick="javascript:hidePop();return false;" Commented Jan 2, 2014 at 10:34

1 Answer 1


apex:commandButton calls server even if action is not specified. In that case properties bound to form fields are updated in the controller, what may involve changes in the page content. As an example consider the below page bound to the standard Account controller:

<apex:page standardController="Account">
    The chosen name is: {!Account.Name}
        <apex:inputField value="{!Account.Name}"/>
        <apex:commandButton value=" Update the page " />

Although no custom controller methods are defined or bound to the button, pressing it reloads the page, what in turn causes the message at the top to be updated.

To prevent the standard action, you can return false in the onclick action or call event.preventDefault(). For more details see the related question on Stackoverflow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .