On my HTML page, when the user clicks / presses F5 button the page refreshes, but before it refreshes I want to execute a function or a simple alert.
Use
the jQuery related event is:
$( window ).on('unload', function( event ) { console.log('Handler for `unload` called.'); });
Works great for me.