阻止跳转的代码:
1 | $(window).on('beforeunload', () => { console.log('leave'); return false; }); |
1 | window.addEventListener('beforeunload', function(){console.log('leave');return false;}); |
参考来源:https://jingyan.baidu.com/article/574c52190bc5ac6c8d9dc196.html
阻止跳转的代码:
1 | $(window).on('beforeunload', () => { console.log('leave'); return false; }); |
1 | window.addEventListener('beforeunload', function(){console.log('leave');return false;}); |
参考来源:https://jingyan.baidu.com/article/574c52190bc5ac6c8d9dc196.html