刷新父窗口
/// <summary>
/// 刷新父窗口
/// </summary>
public static void RefreshParent()
{
string js=@"<Script language='JavaScript'>
parent.location.reload();
</Script>";
HttpContext.Current.Response.Write(js);
}
格式化为JS可解释的字符串
/// <summary>
/// 格式化为JS可解释的字符串
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string JSStringFormat(string s)
{
return s.Replace("\r","\\r").Replace("\n","\\n").Replace("'","\\'").Replace("\"","\\\"");
}
刷新打开窗口
/// <summary>
/// 刷新打开窗口
/// </summary>
public static void RefreshOpener()
{
string js=@"<Script language='JavaScript'>
opener.location.reload();
</Script>";
HttpContext.Current.Response.Write(js);
}
打开窗口
/// <summary>
/// 打开窗口
/// </summary>
/// <param name="url"></param>
public static void OpenWebForm(string url)
{
/**//*…………………………………………………………………………………………*/
/**//*修改目的: 新开页面去掉ie的菜单。。。 */
string js=@"<Script language='JavaScript'>
//window.open('"+url+@"');
window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
</Script>";
/**//*结束*/
/**//*…………………………………………………………………………………………*/
HttpContext.Current.Response.Write(js);
}
public static void OpenWebForm(string url,string name,string future)
{
string js=@"<Script language='JavaScript'>
window.open('"+url+@"','"+name+@"','"+future+@"')
</Script>";
HttpContext.Current.Response.Write(js);
}
public static void OpenWebForm(string url,string formName)
{
/**//*…………………………………………………………………………………………*/
/**//*修改目的: 新开页面去掉ie的菜单。。。 */
/**//*注释内容: */
/**//*开始*/
string js=@"<Script language='JavaScript'>
window.open('"+url+@"','"+formName+@"','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
</Script>";
/**//*结束*/
/**//*…………………………………………………………………………………………*/
HttpContext.Current.Response.Write(js);
}
打开WEB窗口
/// <summary>
/// 函数名:OpenWebForm
/// 功能描述:打开WEB窗口
/// </summary>
/// <param name="url">WEB窗口</param>
/// <param name="isFullScreen">是否全屏幕</param>
public static void OpenWebForm(string url,bool isFullScreen)
{
string js=@"<Script language='JavaScript'>";
if(isFullScreen)
{
js+="var iWidth = 0;";
js+="var iHeight = 0;";
js+="iWidth=window.screen.availWidth-10;";
js+="iHeight=window.screen.availHeight-50;";
js+="var szFeatures ='width=' + iWidth + ',height=' + iHeight + ',top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no';";
js+="window.open('"+url+@"','',szFeatures);";
}
else
{
js+="window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');";
}
js+="</Script>";
HttpContext.Current.Response.Write(js);
}
转向Url制定的页面
/// <summary>
/// 转向Url制定的页面
/// </summary>
/// <param name="url"></param>
public static void JavaScriptLocationHref(string url)
{
string js=@"<Script language='JavaScript'>
window.location.replace('{0}');
</Script>";
js=string.Format(js,url);
HttpContext.Current.Response.Write(js);
}
指定的框架页面转换
/// <summary>
/// 指定的框架页面转换
/// </summary>
/// <param name="FrameName"></param>
/// <param name="url"></param>
public static void JavaScriptFrameHref(string FrameName,string url)
{
string js=@"<Script language='JavaScript'>
@obj.location.replace(""{0}"");
</Script>";
js = js.Replace("@obj",FrameName );
js=string.Format(js,url);
HttpContext.Current.Response.Write(js);
}
重置页面
/// <summary>
///重置页面
/// </summary>
public static void JavaScriptResetPage(string strRows)
{
string js=@"<Script language='JavaScript'>
window.parent.CenterFrame.rows='"+strRows+"';</Script>";
HttpContext.Current.Response.Write(js);
}
客户端方法设置Cookie
/// <summary>
/// 函数名:JavaScriptSetCookie
/// 功能描述:客户端方法设置Cookie
/// </summary>
/// <param name="strName">Cookie名</param>
/// <param name="strValue">Cookie值</param>
public static void JavaScriptSetCookie(string strName,string strValue)
{
string js=@"<script language=Javascript>
var the_cookie = '"+strName+"="+strValue+@"'
var dateexpire = 'Tuesday, 01-Dec-2020 12:00:00 GMT';
//document.cookie = the_cookie;//写入Cookie<BR>} <BR>
document.cookie = the_cookie + '; expires='+dateexpire;
</script>";
HttpContext.Current.Response.Write(js);
}
返回父窗口
/// <summary>
/// 函数名:GotoParentWindow
/// 功能描述:返回父窗口
/// </summary>
/// <param name="parentWindowUrl">父窗口</param>
public static void GotoParentWindow(string parentWindowUrl)
{
string js=@"<Script language='JavaScript'>
this.parent.location.replace('"+parentWindowUrl+"');</Script>";
HttpContext.Current.Response.Write(js);
}
替换父窗口
/// <summary>
/// 函数名:ReplaceParentWindow
/// 功能描述:替换父窗口
/// </summary>
/// <param name="parentWindowUrl">父窗口</param>
/// <param name="caption">窗口提示</param>
/// <param name="future">窗口特征参数</param>
public static void ReplaceParentWindow(string parentWindowUrl,string caption,string future)
{
string js="";
if(future!=null&&future.Trim()!="")
{
js=@"<script language=javascript>this.parent.location.replace('"+parentWindowUrl+"','"+caption+"','"+future+"');</script>";
}
else
{
js=@"<script language=javascript>var iWidth = 0 ;var iHeight = 0 ;iWidth=window.screen.availWidth-10;iHeight=window.screen.availHeight-50;
var szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';this.parent.location.replace('"+parentWindowUrl+"','"+caption+"',szFeatures);</script>";
}
HttpContext.Current.Response.Write(js);
}
替换当前窗体的打开窗口
/// <summary>
/// 函数名:ReplaceOpenerParentWindow
/// 功能描述:替换当前窗体的打开窗口的父窗口
/// </summary>
/// <param name="openerWindowUrl">当前窗体的打开窗口的父窗口</param>
public static void ReplaceOpenerParentFrame(string frameName,string frameWindowUrl)
{
string js=@"<Script language='JavaScript'>
window.opener.parent." + frameName + ".location.replace('"+frameWindowUrl+"');</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 刷新父窗口
/// </summary>
public static void RefreshParent()
{
string js=@"<Script language='JavaScript'>
parent.location.reload();
</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 格式化为JS可解释的字符串
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string JSStringFormat(string s)
{
return s.Replace("\r","\\r").Replace("\n","\\n").Replace("'","\\'").Replace("\"","\\\"");
}
/// <summary>
/// 刷新打开窗口
/// </summary>
public static void RefreshOpener()
{
string js=@"<Script language='JavaScript'>
opener.location.reload();
</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 打开窗口
/// </summary>
/// <param name="url"></param>
public static void OpenWebForm(string url)
{
/**//*…………………………………………………………………………………………*/
/**//*修改目的: 新开页面去掉ie的菜单。。。 */
string js=@"<Script language='JavaScript'>
//window.open('"+url+@"');
window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
</Script>";
/**//*结束*/
/**//*…………………………………………………………………………………………*/
HttpContext.Current.Response.Write(js);
}
public static void OpenWebForm(string url,string name,string future)
{
string js=@"<Script language='JavaScript'>
window.open('"+url+@"','"+name+@"','"+future+@"')
</Script>";
HttpContext.Current.Response.Write(js);
}
public static void OpenWebForm(string url,string formName)
{
/**//*…………………………………………………………………………………………*/
/**//*修改目的: 新开页面去掉ie的菜单。。。 */
/**//*注释内容: */
/**//*开始*/
string js=@"<Script language='JavaScript'>
window.open('"+url+@"','"+formName+@"','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
</Script>";
/**//*结束*/
/**//*…………………………………………………………………………………………*/
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 函数名:OpenWebForm
/// 功能描述:打开WEB窗口
/// </summary>
/// <param name="url">WEB窗口</param>
/// <param name="isFullScreen">是否全屏幕</param>
public static void OpenWebForm(string url,bool isFullScreen)
{
string js=@"<Script language='JavaScript'>";
if(isFullScreen)
{
js+="var iWidth = 0;";
js+="var iHeight = 0;";
js+="iWidth=window.screen.availWidth-10;";
js+="iHeight=window.screen.availHeight-50;";
js+="var szFeatures ='width=' + iWidth + ',height=' + iHeight + ',top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no';";
js+="window.open('"+url+@"','',szFeatures);";
}
else
{
js+="window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');";
}
js+="</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 转向Url制定的页面
/// </summary>
/// <param name="url"></param>
public static void JavaScriptLocationHref(string url)
{
string js=@"<Script language='JavaScript'>
window.location.replace('{0}');
</Script>";
js=string.Format(js,url);
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 指定的框架页面转换
/// </summary>
/// <param name="FrameName"></param>
/// <param name="url"></param>
public static void JavaScriptFrameHref(string FrameName,string url)
{
string js=@"<Script language='JavaScript'>
@obj.location.replace(""{0}"");
</Script>";
js = js.Replace("@obj",FrameName );
js=string.Format(js,url);
HttpContext.Current.Response.Write(js);
}
/// <summary>
///重置页面
/// </summary>
public static void JavaScriptResetPage(string strRows)
{
string js=@"<Script language='JavaScript'>
window.parent.CenterFrame.rows='"+strRows+"';</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 函数名:JavaScriptSetCookie
/// 功能描述:客户端方法设置Cookie
/// </summary>
/// <param name="strName">Cookie名</param>
/// <param name="strValue">Cookie值</param>
public static void JavaScriptSetCookie(string strName,string strValue)
{
string js=@"<script language=Javascript>
var the_cookie = '"+strName+"="+strValue+@"'
var dateexpire = 'Tuesday, 01-Dec-2020 12:00:00 GMT';
//document.cookie = the_cookie;//写入Cookie<BR>} <BR>
document.cookie = the_cookie + '; expires='+dateexpire;
</script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 函数名:GotoParentWindow
/// 功能描述:返回父窗口
/// </summary>
/// <param name="parentWindowUrl">父窗口</param>
public static void GotoParentWindow(string parentWindowUrl)
{
string js=@"<Script language='JavaScript'>
this.parent.location.replace('"+parentWindowUrl+"');</Script>";
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 函数名:ReplaceParentWindow
/// 功能描述:替换父窗口
/// </summary>
/// <param name="parentWindowUrl">父窗口</param>
/// <param name="caption">窗口提示</param>
/// <param name="future">窗口特征参数</param>
public static void ReplaceParentWindow(string parentWindowUrl,string caption,string future)
{
string js="";
if(future!=null&&future.Trim()!="")
{
js=@"<script language=javascript>this.parent.location.replace('"+parentWindowUrl+"','"+caption+"','"+future+"');</script>";
}
else
{
js=@"<script language=javascript>var iWidth = 0 ;var iHeight = 0 ;iWidth=window.screen.availWidth-10;iHeight=window.screen.availHeight-50;
var szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';this.parent.location.replace('"+parentWindowUrl+"','"+caption+"',szFeatures);</script>";
}
HttpContext.Current.Response.Write(js);
}
/// <summary>
/// 函数名:ReplaceOpenerParentWindow
/// 功能描述:替换当前窗体的打开窗口的父窗口
/// </summary>
/// <param name="openerWindowUrl">当前窗体的打开窗口的父窗口</param>
public static void ReplaceOpenerParentFrame(string frameName,string frameWindowUrl)
{
string js=@"<Script language='JavaScript'>
window.opener.parent." + frameName + ".location.replace('"+frameWindowUrl+"');</Script>";
HttpContext.Current.Response.Write(js);
}