常用JavaScript代码提示公共类封装

2019-05-11 21:35:48于丽

page.RegisterClientScriptBlock("clientScript", str);
}
else
{
Alert(page, "页面地址不能为空!");
}
}

/// <summary>
///9 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等)。
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="URL">页面名称</param>
/// <param name="Width">宽度</param>
/// <param name="Height">高度</param>
/// <param name="Left">左边距</param>
/// <param name="Top">上边距</param>
/// <example>
/// PublicJS.OpenIEWindow(page,"weihu.aspx",700,350,10,20);
/// </example>
public static void OpenIEWindows(System.Web.UI.Page page, string URL, int Width, int Height, int Left, int Top)
{
if (URL != null)
{
if (Width == 0 || Height == 0)
{
Alert(page, "页面宽度和高度不能为零!");
return;
}
//string str = "<script language='javascript'><!--
"
// + "window.open('" + URL + "','','location=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width=" + Width + ",height=" + Height + ",left=" + Left + ",top=" + Top + "');"
// + "
// --></script>";
string str = "<script language='javascript'><!--
"
+ "tt = window.open('" + URL + "','','location=no,status=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,fullscreen=no'); tt.focus();"
+ "
// --></script>";

if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", str);
}
else
{
Alert(page, "页面地址不能为空!");
}
}

public static void OpenIEWindows(System.Web.UI.Page page, string URL, int Width, int Height)
{
if (URL != null)
{
if (Width == 0 || Height == 0)
{
Alert(page, "页面宽度和高度不能为零!");
return;
}
string str = "<script language='javascript'><!--
";
str += "a = window.open("" + URL + "", "", "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=" + Width + ",height=" + Height + "", true);";
str += "a.focus();";
str += "
// --></script>";
if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", str);
}
else
{
Alert(page, "页面地址不能为空!");
}
}


/// <summary>
///10 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等)。
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="URL">页面名称</param>
/// <example>
/// PublicJS.OpenIEWindow(page,"weihu.aspx");
/// </example>
public static void OpenIEWindow(System.Web.UI.Page page, string URL)
{
if (URL != null)
{
string str = "<script language='javascript'><!--
"
+ "var Cwin=window.open('" + URL + "','','location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=screen.availWidth-20,height=screen.availHeight-20,left=10,top=10');"