This has / may have been asked before, but, as far as I remember, the question was not satisfactory answered at that time ^^
How can I register a window or tab closi
window.onbeforeunload = function (e) { var e = e || window.event; // For IE and Firefox if (e) { e.returnValue = 'Any string'; } // For Safari return 'Any string'; };