开发者

need to have an alertbox in jsp inorder to close the browser

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>


Use confirm box instead , It should be like

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

See Also

  • how-to-close-current-tab-in-a-browser-window


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜