• 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原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    经典测试面试题一
    自定义函数实现字符串数组互转
    php 实现密码错误三次锁定账号10分钟
    HTTP状态码
    Linux知识点
    慢查日志
    curl 采集
    HTTP协议
    docker配置
    mysql数据库索引、存储引擎、事务
  • 原文地址:https://www.cnblogs.com/newsea/p/1453603.html
Copyright © 2020-2023  润新知