I found the M.util.show_confirm_dialog function in C:\inetpub\wwwroot\lib\javascript-static.js and made a renamed copy of this function within the same file.
Then I modified that function's copy so that now the 'Cancel' button doesn't cancel the operation and closes the dialog, but opens a particalur page. In other words, now instead of the confirmation dialog with 'Confirm' and 'Cancel' buttons, I have a dialog with buttons 'Go to Page 1' and 'Go to Page 2'.
Then I tested my function. It works fine, instead of that the close button (x) acts exactly as 'Go to Page 2' button.
Could I please know, how to change the behavior of the close button (x) so that it just closes the dialog box?