Tuesday, July 19, 2011
Window Close Event of Browser (tested with IE9, Chrome, FF 5.0)

javascript
<--script language="javascript" type="text/javascript">
var isClose = false;
document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event)
keycode = window.event.keyCode;
else if (e)
keycode = e.which;
if (keycode == 116) {
isClose = true;
}
}
function somefunction() {
isClose = true;
}
function doUnload() {
if (!isClose) {
alert('window is closing');
}
}
<--/script>

call the doUnload() function on the body tag onbeforeunload="doUnload()"

0 comments:

About Me

Followers