JavaScript Operation class

Source: Internet
Author: User
Tags httpcontext

public class Javascriptplus
{
Public Javascriptplus ()
{ }
<summary>
Output Custom Script information
</summary>
<param name= "page" > current page pointer, generally this</param>
<param name= "script" > Output script </param>
public static void Responsescript (System.Web.UI.Page Page, String script)
{
Page. Clientscript.registerstartupscript (page. GetType (), "message", "<script language= ' JavaScript ' defer>" + script + "</script>");

}
#region back to the history page
<summary>
Back to History page
</summary>
<param name= "Value" >-1/1</param>
public static void Gohistory (int value)
{
#region
String js = @ "<script language= ' JavaScript ' >
History.go ({0});
</Script> ";
HttpContext.Current.Response.Write (String. Format (JS, value));
#endregion
}
#endregion
#region Close the current window
<summary>
Close the current window
</summary>
public static void CloseWindow ()
{
#region
String js = @ "<script language= ' JavaScript ' >
Parent.opener=null;window.close ();
</Script> ";
HttpContext.Current.Response.Write (JS);
HttpContext.Current.Response.End ();
#endregion
}
#endregion
#region Refresh the parent window
<summary>
Refresh Parent Window
</summary>
public static void Refreshparent (string url)
{
#region
String js = @ "<script>try{top.location=" "" + URL + @ "" "}catch (e) {location=" "" + URL + @ "" "}</script>";
HttpContext.Current.Response.Write (JS);
#endregion
}
#endregion
#region Refresh Open Window
<summary>
Refresh Open Window
</summary>
public static void Refreshopener ()
{
#region
String js = @ "<script language= ' JavaScript ' >
Opener.location.reload ();
</Script> ";
HttpContext.Current.Response.Write (JS);
#endregion
}
#endregion
#region turn to the page specified by the URL
<summary>
Turn to the page specified by the URL
</summary>
<param name= "url" > Connection address </param>
public static void Javascriptlocationhref (string url)
{
#region
String js = @ "<script language= ' JavaScript ' >
Window.location.replace (' {0} ');
</Script> ";
JS = string. Format (JS, url);
HttpContext.Current.Response.Write (JS);
#endregion
}
#endregion
#region Open a modal dialog box with a specified size position
<summary>
Opens a modal dialog box for a specified size position
</summary>
<param name= "Webformurl" > Connection address </param>
<param name= "width" > Width </param>
<param name= "height" > High </param>
<param name= "Top" > Distance up position </param>
<param name= "left" > Distance </param>
public static void Showmodaldialogwindow (string webformurl, int width, int height, int top, int. left)
{
#region
String features = "Dialogwidth:" + width. ToString () + "px"
+ ";d ialogheight:" + height. ToString () + "px"
+ ";d ialogleft:" + left. ToString () + "px"
+ ";d ialogtop:" + top. ToString () + "px"
+ "; Center:yes;help=no;resizable:no;status:no;scroll=yes";
Showmodaldialogwindow (Webformurl, features);
#endregion
}
#endregion
#region Open modal dialog box
<summary>
Open modal dialog box
</summary>
<param name= "Webformurl" > Link address </param>
<param name= "Features" ></param>
public static void Showmodaldialogwindow (string Webformurl, String features)
{
String js = Showmodaldialogjavascript (Webformurl, features);
HttpContext.Current.Response.Write (JS);
}

<summary>
Open modal dialog box
</summary>
<param name= "Webformurl" ></param>
<param name= "Features" ></param>
<returns></returns>
public static string Showmodaldialogjavascript (string Webformurl, String features)
{
#region
String js = @ "<script language=javascript>
ShowModalDialog (' "+ Webformurl +" ', ' ', ' "+ Features +" ');</script> ";
Return JS;
#endregion
}
#endregion
#region Open a new form of the specified size
<summary>
Open a new form of the specified size
</summary>
<param name= "url" > Address </param>
<param name= "width" > Width </param>
<param name= "Heigth" > High </param>
<param name= "Top" > Head position </param>
<param name= "left" > Position </param>
public static void Openwebformsize (string url, int width, int heigth, int top, int. left)
{
#region
String js = @ "<script language= ' JavaScript ' >window.open ('" + URL + @ "', ' ', ' height=" + Heigth + ", width=" + width + " , top= "+ Top +", left= "+ Left +", location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar= No,directories=no ');</script> ";

HttpContext.Current.Response.Write (JS);
#endregion
}
#endregion
<summary>
Page jump (jump out of frame)
</summary>
<param name= "url" ></param>
public static void Javascriptexitifream (string url)
{
String js = @ "<script language= ' JavaScript ' >
Parent.window.location.replace (' {0} ');
</Script> ";
JS = string. Format (JS, url);
HttpContext.Current.Response.Write (JS);
}
}

JavaScript Operation class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.