The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Detect Browser tab closed.

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #150354
    $(document).ready(function() { 
      window.onunload = afterUnload;
    function afterUnload() {
        params  = 'width='+screen.width;
        params += ', height='+screen.height;
        params += ', top=0, left=0'
        params += ', fullscreen=yes';'/Thanks.aspx', '_newtab', params);

    For now i able to detect the browser close and redirect the user to other pages.
    I am using ASP.NET to build my website, and i have multiple child pages under the same master page.
    The problem i faced is whenever i swift to another child page (under the same master page) will redirect me to go Thanks.aspx page.
    Any tricks suggested to avoid this happening? I just want whenever the user is closing the browser/tab only will redirect to the Thanks.aspx page, but not redirect whenever user trying to go another child pages.

    Thanks for in advanced.


    I suggest not doing this at all.

    If someone wants to leave your website, opening a popup instead will only upset them.


    i doing this because my Thanks.aspx having remove cookies.
    if possible then i want detect user close tab but not redirect to another child pages, then remove cookies code will be fired.
    How can i do that?


    Does anyone know how to achieve my requirement?
    Thanks for in advanced.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.