I've found this example:
But it looks to me like it will always call the Apex function. My understanding of what's happening is likely incomplete.
Here's the code I started with. It's a trimmed down version of what I linked to and gets accessed by adding the following to the link onclick="return showConfirmation();"