Link to home
Start Free TrialLog in
Avatar of erenpasa
erenpasa

asked on

javascript cancel close window

hi to all,
(For Internet explorer 7.0)
1-i want to show a message to user when close explorer window. i've done it but when i explore in same domain  the message appear always. I just want to show message when user try to close window. not as surf same domain. if user go another domain so show message too..
2-Is there any way to cancel window close?



window.onbeforeunload = closeWindow;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of random_ru
random_ru
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1- it is impossible to capture the destination url of the next page for security reasons, so you can't do that.

2- you can cancel window close by returning false with
window.onbeforeunload = function() { return false; }
BUT you also can't leave the current page to another, which means it also can't be done.