Created
July 5, 2016 02:44
-
-
Save comeontom/f80681282d6802b384a7dc3822c4c387 to your computer and use it in GitHub Desktop.
页面切换时,弹出提示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 离开页面弹出提示代码: 绑定beforeunload事件 | |
addBeforeunload: function() { | |
this.delBeforeunload(); | |
$(window).bind('beforeunload',function(e){ | |
var confirmationMessage = '确定离开此页吗?本页不需要刷新或后退'; | |
(e || window.event).returnValue = confirmationMessage; | |
return confirmationMessage; | |
}); | |
}, | |
//离开页面弹出提示代码: 解除绑定 | |
delBeforeunload: function() { | |
$(window).unbind('beforeunload'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment