Forums

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

Home Forums JavaScript How to detect exactly browser close?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #151257
    Jack
    Participant

    No matter is browser close or the tab close.
    i want detect exactly is close but not when transferring to another pages.
    Now, i am success to open a new window with new web page, but the problem i faced is when user trying to go another pages, it will show the new window again.
    P/S: i am using ASP.NET to develop my webpage and these code is put under the Master Page

    $(document).ready(function() {    
      window.onbeforeunload = beforeUnload;
      window.onunload = afterUnload;
    });
    function beforeUnload() {
        return "You are attemped to leave the page. Are you sure want to leave MSJ Bank Financial?";
    }
    function afterUnload() {
        params  = 'width='+screen.width;
        params += ', height='+screen.height;
        params += ', top=0, left=0'
        params += ', fullscreen=yes';
        window.open('/Thanks.aspx', '_newtab', params);
        window.focus();
    } 
    
Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.