关闭窗口
/// <summary>
/// 函数名:CloseParentWindow
/// 功能描述:关闭窗口
/// </summary>
public static void CloseParentWindow()
{
string js=@"<Script language='JavaScript'>
window.parent.close();
</Script>";
HttpContext.Current.Response.Write(js);
}
public static void CloseOpenerWindow()
{
string js=@"<Script language='JavaScript'>
window.opener.close();
</Script>";
HttpContext.Current.Response.Write(js);
}
返回打开模式窗口的脚本
/// <summary>
/// 函数名:ShowModalDialogJavascript
/// 功能描述:返回打开模式窗口的脚本
/// </summary>
/// <param name="webFormUrl"></param>
/// <returns></returns>
public static string ShowModalDialogJavascript(string webFormUrl)
{
string 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';
showModalDialog('"+webFormUrl+"','',szFeatures);</script>";
return js;
}
public static string ShowModalDialogJavascript(string webFormUrl,string features)
{
string js=@"<script language=javascript>
showModalDialog('"+webFormUrl+"','','"+features+"');</script>";
return js;
}
/// <summary>
/// 函数名:ShowModalDialogWindow
/// 功能描述:打开模式窗口
/// </summary>
/// <param name="webFormUrl"></param>
/// <returns></returns>
public static void ShowModalDialogWindow(string webFormUrl)
{
string js=ShowModalDialogJavascript(webFormUrl);
HttpContext.Current.Response.Write(js);
}
public static void ShowModalDialogWindow(string webFormUrl,string features)
{
string js=ShowModalDialogJavascript(webFormUrl,features);
HttpContext.Current.Response.Write(js);
}
public static void ShowModalDialogWindow(string webFormUrl,int width,int height,int top,int left)
{
string features = "dialogWidth:"+width.ToString() + "px"
+";dialogHeight:" + height.ToString() + "px"
+";dialogLeft:" + left.ToString() + "px"
+";dialogTop:" + top.ToString() + "px"
+";center:yes;help=no;resizable:no;status:no;scroll=no";
ShowModalDialogWindow(webFormUrl,features);
}
public static void SetHtmlElementValue(string formName,string elementName,string elementValue)
{
string js=@"<Script language='JavaScript'>if(document."+formName+"." + elementName +"!=null){document."+formName+"." + elementName +".value ="+ elementValue +";}</Script>";
HttpContext.Current.Response.Write(js);
}
http://www.cnblogs.com/fds2003/archive/2006/10/20/534208.html