I have the following JavaScript:
var leave_page_confirm = true;
function save_data_check() {
var msg;
if (leave_page_confirm === true) {
$('.input-right').each(function() {
if (this.value) {
msg = 'You have unsaved data on this page.';
return false;
}
});
}
return msg;
}
window.onbeforeunload = save_data_check;
This confirm box displays when you have unsaved data in a form on my pages.
However, when it appears the emphasis (default button) is "Leave This Page" I would like the emphasis to be on "Stay on This Page" despite quite a bit of Googling, I can't seem to find any code that changes the emphasis of the buttons on a confirm alert.
Is there any way to accomplish this?
You might want to refer to this question:
How to personalize alert buttons - window.confirm() and window.alert()
Basically, you can't. But you can make your own modals for this kind of thing and have full control over what it looks like and which buttons are emphasized.