下列方法无论多么复杂的框架都可以关闭浏览器
方法一:
BasePage的写法
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
this.Load+= new EventHandler(BasePage_Load);
}
void BasePage_Load(object sender, EventArgs e)
{
if (Session["userName"] != null
&& Session["pwd"] != null
&& Session["ID"] != null)
{
}
else
{
// 关闭原页面并跳转
Response.Write("<script>alert
('离线时间太长,请重新登录!');top.location.href='/Ucenter/Login.aspx'</script>");
//ClientScript.RegisterClientScriptBlock
(ClientScript.GetType(), "", "<script>alert('请重新登
录!');top.location.href='/UCenter/index.aspx';</script>");
Response.End();
}
}
}
方法二:
有点小烦
function CloseBroswer() {
top.window.opener = top;
top.window.open('', '_self', '');
top.window.close();
}
<a href="../Login.aspx" target="_blank" onclick="CloseBroswer()">退出管理</a>