Click here to Skip to main content
14,335,481 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

Window unload event can help you.

$(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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100