0

I have a function in my jsp to keep track of the session.

Wen the session gets expired, I need to show an alert that the session is over. The box should hav an ok button which, when clicked, I want to close the browser. I did using confirm but confirm seems to have Ok and CANCEl button. I need only Ok button.

<script type="text/javascript">
        var sessionTimeout = 180;
        function Timeout()
        {
            var counter = sessionTimeout;

            sessionTimeout = sessionTimeout - 1;

            if (sessionTimeout >= 0)
                window.setTimeout("Timeout()", 1000);
            else
            {
               alert("Your current Session is over.")

            }

==========================================

I don't need any confirmation from user, just alerting user the session is over and onclicking ok browser should close

        }
  </script>
jmj
  • 237,923
  • 42
  • 401
  • 438
jaisri_88
  • 1
  • 1

2 Answers2

0

Use confirm box instead , It should be like

function close_window() {
    alert("Close Window?");
    windows.close();
  }
}

See Also

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
0

Just alert the user and then close the window

<script type="text/javascript">
    var sessionTimeout = 180;
    function Timeout()
    {
        var counter = sessionTimeout;

        sessionTimeout = sessionTimeout - 1;

        if (sessionTimeout >= 0)
            window.setTimeout("Timeout()", 1000);
        else
        {
           alert("Your current Session is over.");
           window.opener='x';window.close();
        }
    }
</script>
Talha Ahmed Khan
  • 15,043
  • 10
  • 42
  • 49