Don't you need to do create, commit or delete action when your button is triggered? Use a nanoflow.
Download the NanoflowCommons module. At the button set On click action to 'call a nanoflow'. In the nanoflow use the 'ShowConfirmation' javascript activity. After that do your logic.
Do you need to do create, commit or delete action when your button is triggered? Use a microflow.
At the button set On click action to 'call a microflow'. In the button you will see 'Microflow settings'. There you have the option 'Ask confirmation'. In the microflow you just configure the logic you need.