Click here to Skip to main content
15,885,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am having a problem with beforeunload event in IE10 browser,
The problem is when I am in IE10 it gives same X,Y coordinates for each postback , so I am not able to trap whether user is trying to close the browser or not.

This is code snippet:

C#
window.onbeforeunload = confirmExit;
function confirmExit() {
if (!e) var e = window.event;
{
  if (((e.clientX || e.clientX) < 0) || ((e.clientY || e.clientY) < 0))//close button
  {
    return "You are about to close the browser";
  }
  else if (e.altKey == true || e.ctrlKey == true) // ALT + F4
  {
    return "You are about to close the browser";
  }
}
}


Can anyone help on this?

Thanks,
Pratik J
Posted
Comments
Dholakiya Ankit 14-Aug-13 4:47am    
you got error of e is undefined in ie?
Nilesh Agniohtri 14-Aug-13 5:37am    
use onunload event instead
Pratik31.J 14-Aug-13 6:16am    
@Ankit, there is no e undefined error.
@Nilesh, I cannot use onunload because user can't cancel his action from that event.
The problem is in IE10 it gives same 'e.clientY' co-ordinates whether it is browser close or any postback event.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900