|
1. 在Asp.net实用技巧(1) 中提到了如何刷新父页面,那么如果要刷新父页面的父页面的父页面了?那就是刷新祖先页面RefreshAncestorPage。  RefreshAncestorPage#region RefreshAncestorPage
 /**//// <summary>
/// 刷新指定的祖先页面,注意是"祖先页面"
/// </summary>
public static void RefreshAncestorPage(HttpResponse Response ,string targetPageTitle ,bool isCloseCurPage)//targetPageTitle 目标页面的title
 {
StringBuilder scriptString = new StringBuilder();
scriptString.Append("<script language = javascript>");
scriptString.Append("var p = window ;");
scriptString.Append(string.Format("while(p.document.title != ''''{0}'''')" ,targetPageTitle));
scriptString.Append("{");
scriptString.Append("p = p.opener ;");
scriptString.Append("}");
scriptString.Append("p.focus();");
scriptString.Append("p.refresh();");

if (isCloseCurPage )
 {
scriptString.Append( " window.focus();" );
scriptString.Append( " window.opener=null;" );
scriptString.Append( " window.close(); " );
}

scriptString.Append("</"+"script>");

Response.Write(scriptString.ToString());
}

 /**//*
需要在Father页面的html中添加如下脚本(在Header中):
<script language="javascript">
function refresh()
{
&[1] [2] [3] [4] [5] [6] 下一页 |