Is it possible to show a DIV when leaving a page? I have a form that needs to be shown when the user leaves the page.
I can make it so the popup appears upon loading of the page but not when leaving.
Thanks, Mani
www.jsfiddle.net/Sjk9E/4
Is it possible to show a DIV when leaving a page? I have a form that needs to be shown when the user leaves the page.
I can make it so the popup appears upon loading of the page but not when leaving.
Thanks, Mani
www.jsfiddle.net/Sjk9E/4
If I get you correctly, you want to know when a tab/window is effectively closed. Well, afaik your only way in Javascript to detect that kind of stuff are onunload & onbeforeunload events.
Unfortunately (or fortunately?), those events are also fired when you leave a site over a link or your browsers back button. So this is the best answer I can give, I don't think you can natively detect a pure close in Javascript. Correct me if I'm wrong here.
javascript detect browser close tab/close browser
3 seconds of google. Just saying.