Is there any way to have some action performed when the browser close button is clicked?

Comments

2 comments

  • Avatar
    Suhail Faisal

    Hi Gwen,

    You can try the below javascript to show a popup confirmation while closing the browser tab

    var popit = true;
    window.onbeforeunload = function()
    {
    if(popit == true)
    {
    popit = false;
    return "Are you sure you want to leave?";
    }
    }
    0
    Comment actions Permalink
  • Avatar
    Gwen Wilson

    Thank you! This worked perfectly!

    0
    Comment actions Permalink

Please sign in to leave a comment.