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

i don't want to close my page on browser tab close and whole browser close
any idea ???
i used below code but its working only in IE(internet explorer) and also it prevent page to close on back button which should not be done




if (window.event) {
if (window.event.clientX < 40 && window.event.clientY < 0) {}
}
Posted
Comments
Richard Deeming 22-Apr-15 8:09am
   
So you want to make a page that the user cannot close, even if they close the browser?

That sounds suspiciously like malicious code to me.
Umesh Parshad 22-Apr-15 8:38am
   
no actually i want it at very first click....
on 2nd clikc browser/tab should be closed

1 solution

Window unload event can help you.

JavaScript
$(window).unload(function(){
//put your code here which you want to check 
});
   

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