Skip to content

Instantly share code, notes, and snippets.

@CooLNuanfeng
Created July 29, 2015 01:28
Show Gist options
  • Save CooLNuanfeng/1e0aae07f9c89d841caf to your computer and use it in GitHub Desktop.
Save CooLNuanfeng/1e0aae07f9c89d841caf to your computer and use it in GitHub Desktop.
监听窗口关闭事件
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning;
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment