[JS] JavascriptHelp (转载)
2014-03-27 14:05
169 查看
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// <summary> /// 开发人:苏飞 /// 开发时间:2009-09-02 /// 主要功能:JavaScript弹出对话框以及跳转 /// </summary> namespace BaseFunction { public class JavascriptHelp { public JavascriptHelp() { // // TODO: 在此处添加构造函数逻辑 // } public static void Create() { System.Web.HttpContext.Current.Response.Write("<SCRIPT type=\"text/javascript\">"); } public static void Dispose() { System.Web.HttpContext.Current.Response.Write("</SCRIPT>"); } /// <summary> /// 显示对话框 /// </summary> /// <param name="strMsg">显示信息</param> public static void GoTo(string strMsg, string strPath) { Create(); if ((strPath == "") || (strPath == null)) { System.Web.HttpContext.Current.Response.Write(" alert(\"" + strMsg + "\");history.go(-1);"); } else { System.Web.HttpContext.Current.Response.Write("alert('" + strMsg + "');location.href='" + strPath + "';"); } Dispose(); System.Web.HttpContext.Current.Response.End(); } public static void Alert(string msg) { Create(); HttpContext.Current.Response.Write("alert('" + msg + "');"); Dispose(); } /// <summary> /// 打开一个新的网页,但不能设置网面的长宽 /// </summary> /// <param name="strUrl">地址</param> /// <param name="strPara">页面参数</param> public static void OpenNewWindow(string strUrl, int width, int height) { Create(); HttpContext.Current.Response.Write("var l=(window.screen.width/2)-" + width + "/2;"); HttpContext.Current.Response.Write("var t=(window.screen.height/2)-" + height + "/2;"); HttpContext.Current.Response.Write("window.open(url,'NewWindow','width='" + width + "',height='" + height + "',top='+t+',left='+l+',menubar=no,toobar=no,scrollbars=yes,resizable=no,status=no,loation=no');"); Dispose(); } /// <summary> /// 重新定向到一个文件 /// </summary> /// <param name="strUrl">重新指定路径</param> public static void Redirect(string strUrl) { Create(); System.Web.HttpContext.Current.Response.Write("window.location.href='" + strUrl + "';"); Dispose(); } } }
相关文章推荐
- js验证表单大全,超级的强悍的javascript代码(转载)
- javascript Date format(js日期格式化) 转载
- [转载 js]document.body ,window.screen javascript对象属性取值意义
- [转载 js]javascript的陷井
- 转载 【iOS开发】网页JS与OC交互(JavaScriptCore) OC ----->JS
- [转载 js]document.body ,window.screen javascript对象属性取值意义
- Javascript 验证Validator.js 使用全解(转载)
- 大量JavaScript日历控件(some free Calendar control by JS),转载别人的
- [转载 js]javascript的陷井
- JavaScript:引用js文件时的编码格式问题(转载自百度经验)
- 转载 iOS js oc相互调用(JavaScriptCore) --iOS调用js
- 转载 : Javascript js 返回上一页
- javascript单元测试框架mochajs详解(转载)
- javascript 转载:js中innerHTML与innerText的用法与区别
- Javascript 验证Validator.js 使用全解(转载)
- 【转载】JS技巧:Flex与JavaScript的交互:调用JavaScipt或者被JavaScript调用
- javascript笔记——js的阻塞特性[转载]
- [转载 js]JsDoc Toolkit:Javascript文档利器
- <Javascript>理解DOMhelp.js
- 转载--学JS必看-JavaScript数据结构深度剖析