你知道浏览器有个关闭事件吗?如果知道的话,好办了。关闭事件触发另外一个页面A,在另外一个页面后台程序里写时间,到数据库里。然后关闭A页面。<script type="text/javascript"> window.onunload = function ()//.onbeforeunload { window.showModalDialog("WebCloseEvent.aspx?" + new Date(), "", "dialogWidth=0px;dialogHeight=0px;"); }
</script> using System; using Cement.Business; using Woody.ToolSet;public partial class WebCloseEvent : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { BusinessUser.Instance.ClearLoginUser(); JSHelp.Close(); } }
public static void Close() { System.Web.UI.Page currentPage = HttpContext.Current.Handler as Page; if (currentPage == null) return; var s = string.Format("window.close();"); currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(), ran.Next().ToString(), s, true); }
window.onunload = function ()//.onbeforeunload
{
window.showModalDialog("WebCloseEvent.aspx?" + new Date(), "", "dialogWidth=0px;dialogHeight=0px;");
}
</script>
using System;
using Cement.Business;
using Woody.ToolSet;public partial class WebCloseEvent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BusinessUser.Instance.ClearLoginUser();
JSHelp.Close();
}
}
public static void Close()
{
System.Web.UI.Page currentPage = HttpContext.Current.Handler as Page;
if (currentPage == null) return; var s = string.Format("window.close();");
currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(), ran.Next().ToString(), s, true);
}