Close multi opener, parent of a web window and redirect to default home page

assume default home page is default.aspx, default first page is default.htm.

default.htm:

<script type="text/javascript" language="javascript">
        
<!--            
            setTimeout(
'OpenWin()'100);
            
            
function OpenWin()
            
...{
                
if(window.parent != null && window.opener == null)
                
...{
                    window.parent.location 
= "Default.aspx";
                }

                
else if(window.opener != null && !window.opener.closed)
                
...{
                    window.opener.location 
= "default.htm"// recursion to close opener's opener's opener...
                    window.close();
                }

                
else
                
...{
                    window.location 
= "Default.aspx";
                }

            }

        
//-->
    </script>

 

code to redirect to default.htm:

private void ResponseRidirect()
        
...{
            
string currentUrl = this.Request.Url.ToString();
            
string appPath = this.Request.ApplicationPath;
            
int index = currentUrl.IndexOf(appPath);
            
string destUrl = string.Format("{0}/default.htm", currentUrl.Substring(0, index + appPath.Length));

            
string script = "<script language="javascript" type="text/javascript"> " +
                
"window.location = "" + destUrl + ""; " +
                
"</script>";
            Response.Write(script);
            Response.End();
        }

 

 

阅读更多
个人分类: Developer
想对作者说点什么? 我来说一句

parentopener的区别

2009年01月05日 139B 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭