在關閉瀏覽器時前做某些事時...

摘要:在關閉瀏覽器時前做某些事時...

just use this

function HandleOnClose() {
// to load a page
//window.opener.location.href="URL address www. whatever .com";

// alert
alert('You are about to close this page');

}


then put this in the <body onbeforeunload="HandleOnClose()">

should work for both IE7 & IE6 with these scenarios:
- Alt+F4
- Close X button on toolbar
- close X on tab

you can even use it for refreshing the parent page with closing pop-up.
http://forums.devarticles.com/javascript-development-22/closing-the-tabs-with-conformation-in-ie7t-136665.html