<body onbeforeunload="HandleOnClose();">
function HandleOnClose() {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
參考來源:http://www.bigbold.com/snippets/posts/show/142