How can I prevent bootstrap 3 modal from closing when the user refreshes the page? I want the user to close the modal only using the CLOSE button, nothing else.
That can't be done. When the user refreshes the page the modal will be gone.
Your only option would be to re-open the modal on page refresh. To do that you would have to store some variable in a cookie or localStorage to tell you that they haven't yet closed the modal.
Then you could do something like this:
$(function() {
if(cookieOrLocalStorageVariable) {
$('#myModal').modal(options);
}
});
The cookieOrLocalStorageVariable would need to be defined by you and should be set once the modal is shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With