The best option for you is to use a sweet warning, I use it in some projects, and it is very simple and looks good. Try not to use javascript confirmation ... not very professional
https://limonte.imtqy.com/sweetalert2/
You can download it there and see some examples. For your problem, a sweet warning might do something like this:
swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#5bc0de', confirmButtonText: 'Go to cart', cancelButtonText: 'Continue shopping!', confirmButtonClass: 'btn btn-success', cancelButtonClass: 'btn btn-info', buttonsStyling: false}).then(function () {//redirect to the cart pagewindow.location.assign("/thecartpage.yourextension");}, function (dismiss) { // dismiss can be 'cancel', 'overlay', // 'close', and 'timer'... use cancel to this. if (dismiss === 'cancel') {//Here you close the modal swal().close();}})
source share