Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsHi , I had a code that was detecting whether the user has attempted to close the browser or not .
If yes ,then there should be a message ,other wise not .
The code that was working fine ,is like
<html>
<head>
<title>Detecting browser close in IE</title>
<script type="text/javascript">
var message='Browser close attempt is detected';
function ConfirmClose()
{
if (event.clientY < 0)
{
event.returnValue = message;
}
}
</script>
</head>
<body onbeforeunload="ConfirmClo
<h4>Close browser!</h4>
</body>
</html>
This works fine but with two exceptions that I have noticed so far.
1.If the user right-click on the title bar , an option to close the browser appears.Now if he clicks on that close option browser gets closed without any message .
2.If the browser is minimized and the user right-clicks on the minimized browser , an option to close the browser appears.
Now also if close option clicked browser gets closed without any message .
Both of the cases do occur as the condition mentioned in my code i.e.
"event.clientY < 0 " is violated .
What can be generic code to handle these two situations ?
One thing I have noticed that in case 1 and case 2
the event.srcElement is null .
Would adding that check will be a full proof check ?
Any suggestions ?
Regards,
Ayan
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: UnicornBoyPosted on 2008-09-20 at 17:09:53ID: 22532510
Comments are available to members only. Sign up or Log in to view these comments.