閱讀50 返回首頁    go 阿裏雲 go 技術社區[雲棲]


JS排除frame影響的跳轉

 

下列方法無論多麼複雜的框架都可以關閉瀏覽器

 

方法一:

 

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" >退出管理</a>

最後更新:2017-04-02 22:16:23

  上一篇:go Intent對象中內置的Flag總結
  下一篇:go .NET的winform中listview的綁定