I found the code below in stackoverflow and it works fine, but how can I capture <input type="button">?
I tried $('input').on('click'), $('input.button').on('click'), and $('button').on('click') also didn't work. Also is there any method to capture refresh event? Many thanks.
var inFormOrLink;
$('a').on('click', function() { inFormOrLink = true; });
$('form').on('submit', function() { inFormOrLink = true; });
$(window).on("beforeunload", function() {
return inFormOrLink ? "Do you really want to close?" : null;
})