clear session on close of browser jsp

关闭浏览器销毁session

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="DetectBrowserClose.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Code to Detect Browser Close Using jQuery In Asp.Net</title>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
        <script language="javascript" type="text/javascript">
            $(document).ready(function () {
                $(window).bind("beforeunload", function () {
                    return confirm("You are about to close the window");
                });
            });
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Please click on close window
    </div>
    </form>
</body>
</html>

详情参考:

http://www.aspdotnet-pools.com/2014/06/code-to-detect-browser-close-using.html

posted @ 2018-07-05 18:52  习惯沉淀  阅读(362)  评论(0编辑  收藏  举报