Response 弹出js代码的方法
来源:互联网 发布:淘宝卖家上传图片失败 编辑:程序博客网 时间:2024/05/16 06:39
public class Common{public static void Alert(string message) { #region string js = @"<Script language='JavaScript'> alert('" + message + "');</Script>"; HttpContext.Current.Response.Write(js); #endregion } /// <summary> /// 弹出消息框并且转向到新的URL /// </summary> /// <param name="message">消息内容</param> /// <param name="toURL">连接地址</param> public static void AlertAndRedirect(string message, string toURL) { #region string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>"; HttpContext.Current.Response.Write(string.Format(js, message, toURL)); #endregion } /// <summary> /// 回到历史页面 /// </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 } /// <summary> /// 关闭当前窗口 /// </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 } /// <summary> /// 刷新父窗口 /// </summary> public static void RefreshParent(string url) { #region string js = @"<Script language='JavaScript'> window.opener.location.href='" + url + "';window.close();</Script>"; HttpContext.Current.Response.Write(js); #endregion } /// <summary> /// 刷新打开窗口 /// </summary> public static void RefreshOpener() { #region string js = @"<Script language='JavaScript'> opener.location.reload(); </Script>"; HttpContext.Current.Response.Write(js); #endregion } /// <summary> /// 打开指定大小的新窗体 /// </summary> /// <param name="url">地址</param> /// <param name="width">宽</param> /// <param name="heigth">高</param> /// <param name="top">头位置</param> /// <param name="left">左位置</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 } /// <summary> /// 转向Url制定的页面 /// </summary> /// <param name="url">连接地址</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 } /// <summary> /// 打开指定大小位置的模式对话框 /// </summary> /// <param name="webFormUrl">连接地址</param> /// <param name="width">宽</param> /// <param name="height">高</param> /// <param name="top">距离上位置</param> /// <param name="left">距离左位置</param> public static void ShowModalDialogWindow(string webFormUrl, int width, int height, int top, int left) { #region 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=yes"; ShowModalDialogWindow(webFormUrl, features); #endregion } /// <summary> /// 弹出模态窗口 /// </summary> /// <param name="webFormUrl"></param> /// <param name="features"></param> public static void ShowModalDialogWindow(string webFormUrl, string features) { string js = ShowModalDialogJavascript(webFormUrl, features); HttpContext.Current.Response.Write(js); } /// <summary> /// 弹出模态窗口 /// </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}
0 0
- Response 弹出js代码的方法
- 后台代码里执行弹出脚本方法!(Response.Write), Response.Write()彈窗的方法大全
- 后台代码里执行弹出脚本方法!(Response.Write)
- 后台代码里执行弹出脚本方法!(Response.Write)
- 后台代码里执行弹出脚本方法!(Response.Write)
- 后台代码里执行弹出脚本方法!(Response.Write)
- 后台代码里执行弹出脚本方法!(Response.Write)
- js 弹出层的方法
- .CS 中的弹出子窗口的CS代码里 response.write(弹出,跳转(刷新),关闭)
- JS弹出居中的DIV的代码
- JS弹出居中的DIV的代码
- JS弹出居中的DIV的代码
- IE无法屏蔽的弹出页面的方法!Response.Redirect 打开新窗口的两种方法
- JS弹出层代码
- js弹出层代码
- JS定制弹出窗口的居中方法
- js实现div弹出层的方法
- response.write方法生成JAVASCRIPT代码的缺点
- 史上最强图标下载,3124个图标专辑,超过60万免费图标提供下载
- python学习笔记之(四)
- 以后还是来这里写博客吧
- 代码分析ADO.NET数据异步处理
- C#中的索引器的简单理解和用法
- Response 弹出js代码的方法
- nginx的proxy_pass和 location为正则表达式的问题
- Tomcat+MySQL的配置(windows下)
- python入门学习
- Mysql常用的几种SQL提示
- void f() const 常成员函数
- eclipse插件
- 有关“CRT detect that the application wrote to memory after end of heap buffer”问题的解决
- Sql Server 取出多个字段列中的最大值和最小值