I have tried many methods to detect browser close event through jQuery or JavaScript. But, unfortunately, I have not been able to detect the close. The onbeforeunload<
onbeforeunload<
As Phoenix said, use jQuery .bind method, but for more browser compatibility you should return a String,
$(document).ready(function() { $(window).bind("beforeunload", function() { return "Do you really want to close?"; }); });
more details can be found at : developer.mozilla.org