我编写了下面利用javascript编写计算器语言打印ASP.NET网页的代码

JavaScript经典语句及其基本应用_asp.net吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:12,319贴子:
JavaScript经典语句及其基本应用收藏
■打开■ &input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开&
&OBJECT classid=CLSID:A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&&/OBJECT& ■另存为■ &input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为&&OBJECT classid=CLSID:A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&&/OBJECT&
■属性■ &input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性&&OBJECT classid=CLSID:A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&&/OBJECT&
■打印■ &input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印&&OBJECT classid=CLSID:A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&&/OBJECT&
■页面设置■ &input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置&&OBJECT classid=CLSID:A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&&/OBJECT&
■刷新■ &input type=button value=刷新 name=refresh onclick="window.location.reload()"&
■导入收藏■ &input type="button" name="Button" value="导入收藏夹" onClick=window.external.ImportExportFavorites(true,);& ■导出收藏■ &input type="button" name="Button3" value="导出收藏夹" onClick=window.external.ImportExportFavorites(false,);& ■加入收藏■ &INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夹& ■整理收藏夹■ &INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夹& ■查看原文件■ &INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件&■语言设置■ &INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=语言设置&■前进■ &INPUT name=Submit onclick=history.go(1) type=submit value=前进& ■后退■&INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退& 用javascript操作数据库 //用 javascript 写服务器端连接数据库的代码示例 var conn = new ActiveXObject("ADODB.Connection"); conn.Open("Provider=SQLOLEDB.1; Data Source= User ID= " +"Password= Initial Catalog=meizz"); var rs = new ActiveXObject("ADODB.Recordset"); var sql="select user_kind from tbRightSet where user_id=’"+ Account +"’"; rs.open(sql, conn); if (!rs.EOF) { sysUserKind = (rs("user_kind")+"").replace(/^\s+|\s+$/, ""); } rs.close(); rs = conn.close(); conn = &script language="javascript" runat="server"&
//用 javascript 写服务器端连接数据库的代码示例
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB.1; Data Source= User ID= "
+"Password= Initial Catalog=meizz");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select user_kind from tbRightSet where user_id=’"+ Account +"’";
rs.open(sql, conn);
if (!rs.EOF)
sysUserKind = (rs("user_kind")+"").replace(/^\s+|\s+$/, "");
rs.close(); rs = conn.close(); conn =
CSS结合JS的运用 利用CSS配合javascript可以做很多更酷的动态页面效果,现在就简单的给大家简单介绍一下CSS配合JS的应用。首先,我们要搞清楚事件和动作的概念。在客户端脚本中,javascript 通过对事件进行响应来获得与用户的交互。例如,当用户单击一个按钮或者在某段文字上移动鼠标时,就触发了一个单击事件或鼠标移动事件,通过对这些事件的响应,可以完成特定的功能(例如,单击按钮弹出对话框,鼠标移动到文本上后文本变色等)。 下面介绍几种常见的事件(还用更多事件,请查阅相关资料):   onClick:鼠标单击事件。(是指鼠标按下,然后松开时产生。)   onDblClick:鼠标双击事件。(是指鼠标快速按下,松开,并再次按下时产生。)   onMouseDown:鼠标按下事件。(鼠标按下时即产生。)   onMouseUp:鼠标释放事件。(是指鼠标从按下的状态到弹起。)   onMouseMove:鼠标移动事件。(是指在特定元素上移动鼠标。) onMouseOver:鼠标经过事件。(是指,当指针从外界往元素上移动时产生。)   onMouseOut:鼠标离开事件。(是指鼠标从特定元素上离开时产生。)   onLoad:载入事件。(当图象或页面结束载入时产生。)   onUnload:卸载事件。(当访问者离开页面时产生。)   onScroll:滚动条滚动事件。(当访问者使用卷轴上移或下移时产生。)   有了事件以后,我们就为事件加上动作。这里只说改变当前元素自定义样式的动作,我们可以用这个方法先设定好两个自定义的CSS样式,对象原先调用第一种样式,当产生鼠标事件时让对象应用到第二种CSS样式,而产生的鼠标效果,看下面这个例子。   在网页中插入一个图象,自定义一个“.out”样式,用gray滤镜使图片变成黑白的:   将这个自定义样式应用到图片上,在浏览器中预览到图片变成了黑白,我们再定义一个样式“.over”,这个样式没有任何内容,是空样式,样式表代码如下: &style type="text/css"&
.out {filter: Gray}
.over {} .out {filter: Gray} --&   然后在图片标记(IMG)里加上“onMouseOver="this.className=’over’" onMouseOut="this.className=’out’"”,意思为当鼠标经过时,图片为over样式,即彩色正常图象;当鼠标离开时,图片为out样式,即黑白图象。oMouseOver和onMouseOut是鼠标事件,this.className=”…”表示当前对象的class名为…,注意大小写不要写错,JS对大小写非常敏感。   这样这个效果就完成了,保存后在浏览器里打开,图象是黑白的,当鼠标移上去时,图象变成彩色,鼠标离开时,图象又变回黑白。只要发挥你的想象,通过this.className方法还可以做出很多好看的鼠标效果。
怎么感觉javascript这么难嘞
学习学习了................。。。。。。。。。。。。。。。。。。。。。
javascript其实非常简单。
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或常用JavaScript代码提示公共类封装,ASPNET教程,ASPNET案例,ASPNET实例
本站中文域名:、 
        
     
 |  |  |  |  
     |     |     |   
您的位置: &&
&& 常用JavaScript代码提示公共类封装
常用JavaScript代码提示公共类封装
希望对大家有帮助!复制代码 代码如下:using S using System.W namespace Jake.PublicJS { /// &summary& /// Summary description for PublicJS /// &/summary& public class PublicJS { public PublicJS() { // // TODO: Add constructor logic here // } /// &summary& /// 1.静态方法,弹出信息窗体 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="description"&信息内容&/param& /// &example& /// PublicJS.Alert(this,"NiHao!"); /// &/example& public static void Alert(System.Web.UI.Page page, string description) { if (description != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + description + ");"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } else { Alert(page, "描述信息为空!"); } } /// &summary& /// 2.静态方法,弹出信息窗体,并刷新页面 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="description"&信息内容&/param& /// &example& /// PublicJS.Alert(this,"NiHao!"); /// &/example& public static void ReLoadMessage(System.Web.UI.Page page, string description, string PageID) { if (description != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + description + ");"; scriptString += "parent." + PageID + ".location.reload()"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } else { Alert(page, "描述信息为空!"); } } public static void Redirect(string url) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("window.location=" + url + ";\n"); Response.Write(" // --&&/script&\n"); } /// &summary& /// 弹出对话框,转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& /// &param name="url"&页面&/param& public static void MsgBoxRedrict(string description, string url) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("alert(" + description + ");\n"); Response.Write("window.location=" + url + ";\n"); Response.Write(" // --&&/script&\n"); //Response.Redirect(url); } /// &summary& /// 弹出对话框,确实转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& /// &param name="url"&页面&/param& /// &param name="PrintUrl"&确定后转向的页面&/param& public static void MsgBoxRedrict(string description, string url, string PrintUrl) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("function prints()\n"); Response.Write("{\n if(confirm(" + description + "))\n"); Response.Write("{window.location=" + PrintUrl + ";}\n"); Response.Write("else\n"); Response.Write("{window.location=" + url + ";}\n}\n"); Response.Write("prints();\n"); Response.Write(" // --&&/script&\n"); } /// &summary& /// 弹出对话框,转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& public static void MsgBoxRedrict(string description) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("alert(" + description + ");\n"); Response.Write("history.go(-1);\n"); Response.Write(" // --&&/script&\n"); } /// &summary& ///2 静态方法,关闭一个网页的父窗口,例如一个frame关闭其父窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseParent(this); /// &/example& public static void CloseParent(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.parent.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///2 静态方法,关闭一个网页窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseParent(this); /// &/example& public static void ClosePage(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///3 静态方法,输出一则消息后关闭一个模态网页窗口并刷新父窗口 /// 前提条件是必须调用此类中的OpenModalDialog方法 /// 在该方法中自动生成刷新方法才能实现父页面刷新&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="page"&输出消息&/param& /// &example& /// PublicJS.CloseModalDialog(this); /// &/example& public static void CloseModalDialogMessage(System.Web.UI.Page page, string Message) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + Message + ");"; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///3 静态方法,关闭一个模态网页窗口并刷新父窗口 /// 前提条件是必须调用此类中的OpenModalDialog方法 /// 在该方法中自动生成刷新方法才能实现父页面刷新&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseModalDialog(this); /// &/example& public static void CloseModalDialog(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& /// 关闭模态网页并传值到父页面 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="strValue"&需要传递的值&/param& public static void CloseModalDialog(System.Web.UI.Page page, string strValue) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.returnValue=" + strValue.Trim() + ";"; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///4 静态方法,关闭一个网页窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseWindow(this); /// &/example& public static void CloseWindow(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.opener="; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///5 静态方法,执行客户端一小块脚本语言, ///利用page的RegisterClientScriptBlock方法在客户端注册一段脚本, ///参数script无需包括html标记&script type="text/javascript"&&!-- 、 // --&&/script&&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="script"&javascript脚本&/param& /// &example& /// PublicJS.ExecuteBlock(this,"alert("Hello");"); /// &/example& public static void ExecuteBlock(System.Web.UI.Page page, string script) { if (script != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript9")) page.RegisterClientScriptBlock("clientScript9", scriptString); } else { Alert(page, "JavaScript脚本不能为空!"); } } /// &summary& ///6&&&&静态方法,打开一个网页对话框,并生成刷新页面方法&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenModalDialog(page,"weihu.aspx",700,350); /// &/example& public static void OpenModalDialog(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string scriptString = "&script language=javascript&&!-- "; scriptString += "function Refreshs()"; scriptString += "{"; //scriptString += "window.location.href= window.location."; scriptString += "}"; scriptString += "window.showModalDialog(" + URL + ",window,dialogHeight:" + Height + "dialogWidth:" + Width + "center:Yhelp:No;scroll:resizable:No;status:No;);"; scriptString += "window.location.href= window.location."; scriptString += " // --&&/script&"; if (!page.IsStartupScriptRegistered("Startup")) page.RegisterStartupScript("Startup", scriptString); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///7&&&&静态方法,打开一个模式对话框 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Attribute"&属性&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenModalDialog(page,"weihu.aspx","scrollbars=yes,status=yes",700,350); /// &/example& public static void OpenModalDialog(System.Web.UI.Page page, string URL, string Attribute, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} if (Attribute == "") Attribute = "center:Yhelp:No;scroll:No;resizable:No;status:No;"; string scriptString = "&script language=javascript&&!-- "; //scriptString += "function Refresh()"; //scriptString += "{";&&&&&&&&&&&&&&&&&&&& scriptString += "window.showModalDialog(" + URL + ",window,dialogHeight:" + Height + "dialogWidth:" + Width + "" + Attribute + ")"; //scriptString += "&&&&window.location.href= window.location.";&&&& //scriptString += "}"; //scriptString += " Refresh();"; scriptString += " // --&&/script&"; if (!page.IsStartupScriptRegistered("Startup")) page.RegisterStartupScript("Startup", scriptString); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///8 静态方法,打开一个无模式网页对话框&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenDialog(page,"weihu.aspx",700,350); /// &/example& public static void OpenDialog(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=auto,resizable=Yes,width=" + Width + ",height=" + Height + ")" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) 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 OpenIEWindow(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, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "tt = window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ",left=" + Left + ",top=" + Top + "); tt.focus();" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) 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, "页面宽度和高度不能为零!");
} //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, "页面宽度和高度不能为零!");
} 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);" + "Cwin.resizeTo(screen.availWidth-20,screen.availHeight-20);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///11 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等)&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenIEWindow(page,"weihu.aspx",700,350); /// &/example& public static void OpenIEWindow(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { string str = "&script language=javascript&&!-- " + "var Cwin=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ",left=10,top=10);" + "Cwin.moveTo((screen.availWidth-" + Width + ")/2,(screen.availHeight-" + Height + ")/2);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///12 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等) ///在屏幕的最右边,上下满屏,宽度由参数指定&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &example& /// PublicJS.OpenIEWindowRight(page,"weihu.aspx",700); /// &/example& public static void OpenIEWindowRight(System.Web.UI.Page page, string URL, int Width) { if (URL != null) { if (Width == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "newwindow=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + Width + ",height=document.height);" + "newwindow.moveTo(screen.width-" + Width + ",0);newwindow.resizeTo(" + Width + ",screen.height);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///13&&&&静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等),在屏幕的最右边,上下位置在中间&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenIEWindowRight(page,"weihu.aspx",700,350); /// &/example& public static void OpenIEWindowRight(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "newwindow=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ");" + "newwindow.moveTo(screen.width-" + Width + ",(screen.height-" + Height + ")/2);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& /// 设置控件焦点 /// &/summary& /// &param name="kongjianmc"&控件字符串&/param& public static void SheZhiJD(System.Web.UI.Page page, string kongjianmc) { string jiaoben = ""; if (kongjianmc != "") { jiaoben = ""; jiaoben += "control = document.getElementById(" + kongjianmc + ");"; jiaoben += "if (control!=null) "; jiaoben += "{document.all[" + kongjianmc + "].focus();}"; page.RegisterStartupScript("focus", "&script type="text/javascript"&&!-- " + jiaoben + " // --&&/script&"); } } /// &summary& ///14 静态方法,全屏打开一个IE窗口(无标题栏、工具栏、地址栏等)&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &example& /// PublicJS.OpenIEWindow(page,"weihu.aspx"); /// &/example& public static void OpenIEWindowFill(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=no,resizable=no,width=(screen.availWidth),height=(screen.availheight),left=10,top=10);" //+ "alert(screen.availWidth);alert(screen.availheight); Cwin.moveTo(0,0);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } } }
希望对大家有帮助!复制代码 代码如下:using S using System.W namespace Jake.PublicJS { /// &summary& /// Summary description for PublicJS /// &/summary& public class PublicJS { public PublicJS() { // // TODO: Add constructor logic here // } /// &summary& /// 1.静态方法,弹出信息窗体 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="description"&信息内容&/param& /// &example& /// PublicJS.Alert(this,"NiHao!"); /// &/example& public static void Alert(System.Web.UI.Page page, string description) { if (description != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + description + ");"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } else { Alert(page, "描述信息为空!"); } } /// &summary& /// 2.静态方法,弹出信息窗体,并刷新页面 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="description"&信息内容&/param& /// &example& /// PublicJS.Alert(this,"NiHao!"); /// &/example& public static void ReLoadMessage(System.Web.UI.Page page, string description, string PageID) { if (description != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + description + ");"; scriptString += "parent." + PageID + ".location.reload()"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } else { Alert(page, "描述信息为空!"); } } public static void Redirect(string url) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("window.location=" + url + ";\n"); Response.Write(" // --&&/script&\n"); } /// &summary& /// 弹出对话框,转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& /// &param name="url"&页面&/param& public static void MsgBoxRedrict(string description, string url) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("alert(" + description + ");\n"); Response.Write("window.location=" + url + ";\n"); Response.Write(" // --&&/script&\n"); //Response.Redirect(url); } /// &summary& /// 弹出对话框,确实转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& /// &param name="url"&页面&/param& /// &param name="PrintUrl"&确定后转向的页面&/param& public static void MsgBoxRedrict(string description, string url, string PrintUrl) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("function prints()\n"); Response.Write("{\n if(confirm(" + description + "))\n"); Response.Write("{window.location=" + PrintUrl + ";}\n"); Response.Write("else\n"); Response.Write("{window.location=" + url + ";}\n}\n"); Response.Write("prints();\n"); Response.Write(" // --&&/script&\n"); } /// &summary& /// 弹出对话框,转向所指页面 /// &/summary& /// &param name="description"&提示信息&/param& public static void MsgBoxRedrict(string description) { HttpResponse R Response = HttpContext.Current.R Response.Write("&script language=JScript&&!-- \n"); Response.Write("alert(" + description + ");\n"); Response.Write("history.go(-1);\n"); Response.Write(" // --&&/script&\n"); } /// &summary& ///2 静态方法,关闭一个网页的父窗口,例如一个frame关闭其父窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseParent(this); /// &/example& public static void CloseParent(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.parent.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///2 静态方法,关闭一个网页窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseParent(this); /// &/example& public static void ClosePage(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///3 静态方法,输出一则消息后关闭一个模态网页窗口并刷新父窗口 /// 前提条件是必须调用此类中的OpenModalDialog方法 /// 在该方法中自动生成刷新方法才能实现父页面刷新&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="page"&输出消息&/param& /// &example& /// PublicJS.CloseModalDialog(this); /// &/example& public static void CloseModalDialogMessage(System.Web.UI.Page page, string Message) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "alert(" + Message + ");"; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///3 静态方法,关闭一个模态网页窗口并刷新父窗口 /// 前提条件是必须调用此类中的OpenModalDialog方法 /// 在该方法中自动生成刷新方法才能实现父页面刷新&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseModalDialog(this); /// &/example& public static void CloseModalDialog(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& /// 关闭模态网页并传值到父页面 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="strValue"&需要传递的值&/param& public static void CloseModalDialog(System.Web.UI.Page page, string strValue) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.returnValue=" + strValue.Trim() + ";"; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///4 静态方法,关闭一个网页窗口&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &example& /// PublicJS.CloseWindow(this); /// &/example& public static void CloseWindow(System.Web.UI.Page page) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += "window.opener="; scriptString += "window.close();"; scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", scriptString); } /// &summary& ///5 静态方法,执行客户端一小块脚本语言, ///利用page的RegisterClientScriptBlock方法在客户端注册一段脚本, ///参数script无需包括html标记&script type="text/javascript"&&!-- 、 // --&&/script&&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="script"&javascript脚本&/param& /// &example& /// PublicJS.ExecuteBlock(this,"alert("Hello");"); /// &/example& public static void ExecuteBlock(System.Web.UI.Page page, string script) { if (script != null) { string scriptString = "&script language=JavaScript&&!-- "; scriptString += scriptString += " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript9")) page.RegisterClientScriptBlock("clientScript9", scriptString); } else { Alert(page, "JavaScript脚本不能为空!"); } } /// &summary& ///6&&&&静态方法,打开一个网页对话框,并生成刷新页面方法&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenModalDialog(page,"weihu.aspx",700,350); /// &/example& public static void OpenModalDialog(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string scriptString = "&script language=javascript&&!-- "; scriptString += "function Refreshs()"; scriptString += "{"; //scriptString += "window.location.href= window.location."; scriptString += "}"; scriptString += "window.showModalDialog(" + URL + ",window,dialogHeight:" + Height + "dialogWidth:" + Width + "center:Yhelp:No;scroll:resizable:No;status:No;);"; scriptString += "window.location.href= window.location."; scriptString += " // --&&/script&"; if (!page.IsStartupScriptRegistered("Startup")) page.RegisterStartupScript("Startup", scriptString); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///7&&&&静态方法,打开一个模式对话框 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Attribute"&属性&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenModalDialog(page,"weihu.aspx","scrollbars=yes,status=yes",700,350); /// &/example& public static void OpenModalDialog(System.Web.UI.Page page, string URL, string Attribute, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} if (Attribute == "") Attribute = "center:Yhelp:No;scroll:No;resizable:No;status:No;"; string scriptString = "&script language=javascript&&!-- "; //scriptString += "function Refresh()"; //scriptString += "{";&&&&&&&&&&&&&&&&&&&& scriptString += "window.showModalDialog(" + URL + ",window,dialogHeight:" + Height + "dialogWidth:" + Width + "" + Attribute + ")"; //scriptString += "&&&&window.location.href= window.location.";&&&& //scriptString += "}"; //scriptString += " Refresh();"; scriptString += " // --&&/script&"; if (!page.IsStartupScriptRegistered("Startup")) page.RegisterStartupScript("Startup", scriptString); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///8 静态方法,打开一个无模式网页对话框&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenDialog(page,"weihu.aspx",700,350); /// &/example& public static void OpenDialog(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=auto,resizable=Yes,width=" + Width + ",height=" + Height + ")" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) 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 OpenIEWindow(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, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "tt = window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ",left=" + Left + ",top=" + Top + "); tt.focus();" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) 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, "页面宽度和高度不能为零!");
} //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, "页面宽度和高度不能为零!");
} 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);" + "Cwin.resizeTo(screen.availWidth-20,screen.availHeight-20);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///11 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等)&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenIEWindow(page,"weihu.aspx",700,350); /// &/example& public static void OpenIEWindow(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { string str = "&script language=javascript&&!-- " + "var Cwin=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ",left=10,top=10);" + "Cwin.moveTo((screen.availWidth-" + Width + ")/2,(screen.availHeight-" + Height + ")/2);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///12 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等) ///在屏幕的最右边,上下满屏,宽度由参数指定&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &example& /// PublicJS.OpenIEWindowRight(page,"weihu.aspx",700); /// &/example& public static void OpenIEWindowRight(System.Web.UI.Page page, string URL, int Width) { if (URL != null) { if (Width == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "newwindow=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + Width + ",height=document.height);" + "newwindow.moveTo(screen.width-" + Width + ",0);newwindow.resizeTo(" + Width + ",screen.height);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& ///13&&&&静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等),在屏幕的最右边,上下位置在中间&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &param name="Width"&宽度&/param& /// &param name="Height"&高度&/param& /// &example& /// PublicJS.OpenIEWindowRight(page,"weihu.aspx",700,350); /// &/example& public static void OpenIEWindowRight(System.Web.UI.Page page, string URL, int Width, int Height) { if (URL != null) { if (Width == 0 || Height == 0) { Alert(page, "页面宽度和高度不能为零!");
} string str = "&script language=javascript&&!-- " + "newwindow=window.open(" + URL + ",,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + ");" + "newwindow.moveTo(screen.width-" + Width + ",(screen.height-" + Height + ")/2);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } /// &summary& /// 设置控件焦点 /// &/summary& /// &param name="kongjianmc"&控件字符串&/param& public static void SheZhiJD(System.Web.UI.Page page, string kongjianmc) { string jiaoben = ""; if (kongjianmc != "") { jiaoben = ""; jiaoben += "control = document.getElementById(" + kongjianmc + ");"; jiaoben += "if (control!=null) "; jiaoben += "{document.all[" + kongjianmc + "].focus();}"; page.RegisterStartupScript("focus", "&script type="text/javascript"&&!-- " + jiaoben + " // --&&/script&"); } } /// &summary& ///14 静态方法,全屏打开一个IE窗口(无标题栏、工具栏、地址栏等)&。 /// &/summary& /// &param name="page"&页面对象&/param& /// &param name="URL"&页面名称&/param& /// &example& /// PublicJS.OpenIEWindow(page,"weihu.aspx"); /// &/example& public static void OpenIEWindowFill(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=no,resizable=no,width=(screen.availWidth),height=(screen.availheight),left=10,top=10);" //+ "alert(screen.availWidth);alert(screen.availheight); Cwin.moveTo(0,0);" + " // --&&/script&"; if (!page.IsClientScriptBlockRegistered("clientScript")) page.RegisterClientScriptBlock("clientScript", str); } else { Alert(page, "页面地址不能为空!"); } } } }
Google搜索中
搜狗搜索中
在线教程导航
数据库开发
产品库推荐
| 站长工具:
All Rights Reserved.
珠江路在线版权所有
苏ICP备号 中文域名:
 |  | 

我要回帖

更多关于 javascript 组件编写 的文章

 

随机推荐