I have a Visualforce page with a custom link that calls a function in the page's controller extension. Before that function gets called, I'd like to use JavaScript to pop up an confirmation dialog box along the lines of "You have chosen to mark this item as resolved. Your name will be added to the comments. OK/Cancel". If OK is clicked, we proceed to the Apex function call. If Cancel is clicked, nothing happens.
I've found this example:
Custom JS confirm button for IF
But it looks to me like it will always call the Apex function. My understanding of what's happening is likely incomplete.
I'm not using any JavaScript packages at present. I'd like to keep things that way if possible.
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();"
<apex:outputPanel id="sendScript">
<script type="text/javascript">
function showConfirmation() {
return confirm('All selected items will be marked resolved. Your name will be added to the comments.');
}
</script>
</apex:outputPanel>