zoukankan      html  css  js  c++  java
  • Session 超时弹出登录框。

                                //在Ajax 里 在脚本里 添加 top ,可把IE搞死.
                                string strJs =
                                    CmnProc.GetJsInclude(
                                        (HttpContext.Current.Handler 
    as Page).ClientScript.GetWebResourceUrl(BuildManager.GetType("WebCon._Page_Resource"false), "WebCon.jquery-1.3.1.js")
                                        , 
    false"""")
                                         
    +
                                    CmnProc.GetJsInclude(
                                        (HttpContext.Current.Handler 
    as Page).ClientScript.GetWebResourceUrl(BuildManager.GetType("WebCon._Page_Resource"false), "WebCon.NewCmn.js")
                                        , 
    false"""")
                                         
    +
                                    CmnProc.GetJsInclude(
                                        (HttpContext.Current.Handler 
    as Page).ClientScript.GetWebResourceUrl(BuildManager.GetType("WebCon._Page_Resource"false), "WebCon.jquery.corner.js")
                                        , 
    false"""")
                                         
    +
                                    
    string.Format(@"
                <script>
                if ( typeof(window.dialogArguments) != ""undefined"" && typeof(window.opener) == ""undefined"")
                {{
                    $(""form"").html(""<div style='100%;height: 100%;text-align:center;vertical-align:middle'><br/><br/><br/><br/><br/>操作已超时, 请刷新主窗体进行登录!</div>"");
                }}
                else
                {{
                    var pw = top ;
                    if ( pw.frameElement !=null )
                    {{
                        pw = pw.frameElement  ;
                    }}
                    if ( pw.ownerDocument != null )
                    {{
                        pw = pw.ownerDocument ;
                    }}
                    if ( pw.parentWindow != null )
                    {{
                        pw = pw.parentWindow ;
                    }}
                    if ( pw.top != null )
                    {{
                        pw = pw.top ;
                    }}
                    if( pw.Popd == undefined || pw.Popd == null)
                    {{
                    pw.Popd = 1 ;
                
                    $(""form"").html("""");
                
                    document.clear();
                    document.writeln(""正在刷新登录,请稍等."") ;
                
                    var sFeature = 'dialogWidth:380px; dialogHeight:300px; center:yes; help:no; resizeble:no; scroll:no; status:no';
                    var retVal = showModalDialog(""{0}"",'',sFeature) ;
                
                    if ( retVal == true || retVal == 'true' )
                    {{
                        if ( top.location.href.indexOf('#') < 0 )
                        {{
                            top.location = top.location.href ;
                        }}
                        else
                        {{
                            top.location = top.location.href.substr(0 ,top.location.href.indexOf('#')) ;
                        }}
                    }}
                    }}
                }}
                </script>
    ""Admin/LoginPop.aspx".GetUrlFull());

                                ScriptManager sm 
    = ScriptManager.GetCurrent(HttpContext.Current.Handler as Page);

                                
    if (sm == null)
                                {
                                    HttpContext.Current.Response.Write(strJs);
                                    
    //HttpContext.Current.Response.End();
                                }
                                
    else
                                {
                                    ScriptManager.RegisterStartupScript(HttpContext.Current.CurrentHandler 
    as Page, typeof(string), "login", strJs, false);
                                }
                                
    //ScriptManager.RegisterStartupScript(HttpContext.Current.CurrentHandler as Page, typeof(string), "login", strJs, false);
                            }

    在超时后, 会弹出登录框,即使弹出登录框,它也会执行页面的Load 事件或回发事件。

    alarm   作者:NewSea     出处:http://newsea.cnblogs.com/    QQ,MSN:iamnewsea@hotmail.com

      如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    WEB安全 php+mysql5注入防御(一)
    Spring 整合 Quartz 实现动态定时任务(附demo)
    dubbo工作原理(3)
    dubbo服务降级(2)
    dubbo服务降级(1)
    程序员决对不能缺少产品思维
    GNUPG
    idea远程debug:tomcat
    基于JavaMail的Java邮件发送:复杂邮件发送
    使用javaMail发送简单邮件
  • 原文地址:https://www.cnblogs.com/newsea/p/1453603.html
Copyright © 2011-2022 走看看