Capturing result of [removed] confirmation dialog

后端 未结 3 940
清歌不尽
清歌不尽 2020-12-03 17:14

Is there a way to capture to result of the window.onbeforeunload confirmation dialog like the one below from Stack Overflow (this happens when leaving the \'Ask Question\' p

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 17:54

    How about this:

    $( window ).bind( 'beforeunload' , function( event ) {
        setTimeout( function() {
            alert( 'Hi againe!' );
        } );
        return '';
    } ).bind( 'unload', function( event ) {
        alert( 'Goodby!' );
    } );
    

提交回复
热议问题