Hi,
Even I am trying the browser close event for cross browser and this should trigger only when X button is clicked or page is refreshed. Here's the code pasted above which I am using but it only works in IE.
I know the issue is because of window.events and ClientX/ClientY.
Could someone please fix my code to make it work in all browsers? This is very urgent and have been striving since 3 days...
*Please Note: Current code is working in IE only and to check you have to close the browser window or refresh the page with mouse click
=====================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><head>
<title>Warning Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript">
// warning message javascript
var isOpera, isIE, isNav, isFox, isOther = false;
if (navigator.userAgent.indexOf("Opera") != -1) {
isOpera = true;
} else if (navigator.userAgent.indexOf("Firefox") != -1) {
isFox = true;
} else if (navigator.appName == "Microsoft Internet Explorer") {
isIE = true;
} else if (navigator.appName == "Netscape") {
isNav = true;
} else {
isOther = true;
}
if (isIE || isOpera || isNav || isFox || isOther) {
window.onbeforeunload = WarnUser;
function WarnUser() {
OffsetX = window.event.clientX;
OffsetY = window.event.clientY;
if (((window.event.clientX < 0) || (window.event.clientY < 0))
&& (isWarnUser == true)) {
event.returnValue = " ";
//window. önunload = sessionInvalidate;
} else {
// Reset the flag to its default value.
isWarnUser = true;
}
}
}
</script>
</head>
<body>
<script type="text/javascript">
var isWarnUser = true;
</script>
test
</body>
</html>
========================