js prompt when user tries to close tab code example Example: js ask before close window.onbeforeunload = function() { return ""; }