| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System.Web;
- namespace CallCenter.Utility
- {
- /// <summary>
- /// JScript 的摘要说明
- /// 在开发过程中可以用的一些技巧文件
- ///本js也是从别的oa中提取来的
- /// </summary>
- public static class Jscript
- {
- /// <summary>
- /// 弹出JavaScript小窗口,并转向指定的页面
- /// </summary>
- /// <param name="message">弹出信息</param>
- /// <param name="toURL">专转向的网页</param>
- public static void AlertAndRedirect(string message, string toURL)
- {
- string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
- HttpContext.Current.Response.Write(string.Format(js, message, toURL));
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript小窗口,并转向来源页
- /// </summary>
- /// <param name="message">弹出信息</param>
- public static void AlertAndRedirect(string message)
- {
- string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
- HttpContext.Current.Response.Write(string.Format(js, message, HttpContext.Current.Request.RawUrl));
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript小窗口,并向父页转向指定的页面
- /// </summary>
- /// <param name="message">弹出信息</param>
- /// <param name="toURL">转向的网页</param>
- public static void AlertAndRedirectTop(string message, string toURL)
- {
- string js = "<script language=javascript>alert('{0}');window.top.location.replace('{1}')</script>";
- HttpContext.Current.Response.Write(string.Format(js, message, toURL));
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript是/否小窗口,并转向指定的页面
- /// </summary>
- /// <param name="message">弹出是/否信息</param>
- /// <param name="YESURL">是:转向的网页</param>
- /// <param name="NOURL">否:转向的网页</param>
- public static void confirm(string message, string YESURL, string NOURL)
- {
- string js = "<script language=javascript>if (!confirm('" + message + "')) {window.location.replace('" + NOURL + "')} else {window.location.replace('" + YESURL + "')} </script>";
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript小窗口
- /// </summary>
- public static void Alert(string message)
- {
- string js = @"<Script language='JavaScript'>alert('" + message + "');</Script>";
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript小窗口并关闭窗口
- /// </summary>
- public static void AlertAndCloseWindow(string message)
- {
- string js = @"<Script language='JavaScript'>alert('" + message + "');window.close();</Script>";
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 弹出JavaScript小窗口,回到历史页面
- /// </summary>
- /// <param name="message">消息</param>
- /// <param name="value">-1/1</param>
- public static void GoHistory(string message, int value)
- {
- string js = @"<Script language='JavaScript'>alert('{0}');history.go({1});</Script>";
- HttpContext.Current.Response.Write(string.Format(js, message, value));
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 关闭当前窗口
- /// </summary>
- public static void CloseWindow()
- {
- string js = @"<Script language='JavaScript'>
- window.close();
- </Script>";
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 转向Url指定的页面
- /// </summary>
- /// <param name="url"></param>
- public static void JSRedirectUrl(string url)
- {
- string js = @"<Script language='JavaScript'>
- window.location.replace('{0}');
- </Script>";
- js = string.Format(js, url);
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 父页转向Url指定的页面
- /// </summary>
- /// <param name="url"></param>
- public static void JSTopRedirectUrl(string url)
- {
- string js = @"<Script language='JavaScript'>
- window.top.location.replace('{0}');
- </Script>";
- js = string.Format(js, url);
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- /// <summary>
- /// 新窗口打开
- /// </summary>
- /// <param name="url"></param>
- public static void JSOpenUrl(string url)
- {
- string js = @"<Script language='JavaScript'>
- window.open('{0}');
- </Script>";
- js = string.Format(js, url);
- HttpContext.Current.Response.Write(js);
- HttpContext.Current.Response.End();
- }
- }
- }
|