<script>
window.onbeforeunload = function() {
return "Are you sure?";
};
</script>
or
$(window).on('beforeunload', function() {
return 'Your own message goes here...';
});
in chorme there are several blocked method on onbeforeunload like alert..
A chorme example of the debugging console for an alert:
Blocked alert('My Window is reloading') during beforeunload.