Have you ever needed some confirmation from user before he makes some action on page, for example before deleting? Solution is simpler than you think. Use standard Javascript popup window confirm();

Here is a simple example:

Do it in this way, because if you will use rerender on commandButton, action cannot fire. Visualforce will add some more javascript after yours in onclick parameter, leading to a conflict. As a result, Salesforce code will never run.

For example something like this:

will never work!

Be careful when using ‘return true/false’ for javascript in Visualforce.