JavascriptHelp
生活随笔
收集整理的這篇文章主要介紹了
JavascriptHelp
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
閱讀全文:http://www.cckan.net/forum.php?mod=viewthread&tid=147 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>
///?開發(fā)人:蘇飛
///?開發(fā)時間:2009-09-02
///?主要功能:JavaScript彈出對話框以及跳轉(zhuǎn)
///?</summary>
namespace?BaseFunction
{
????public?class?JavascriptHelp
????{
????????public?JavascriptHelp()
????????{
????????????//
????????????//?TODO:?在此處添加構(gòu)造函數(shù)邏輯
????????????//
????????}
????????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>
????????///?打開一個新的網(wǎng)頁,但不能設(shè)置網(wǎng)面的長寬
????????///?</summary>
????????///?<param?name="strUrl">地址</param>
????????///?<param?name="strPara">頁面參數(shù)</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();
????????}
????}
}
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>
///?開發(fā)人:蘇飛
///?開發(fā)時間:2009-09-02
///?主要功能:JavaScript彈出對話框以及跳轉(zhuǎn)
///?</summary>
namespace?BaseFunction
{
????public?class?JavascriptHelp
????{
????????public?JavascriptHelp()
????????{
????????????//
????????????//?TODO:?在此處添加構(gòu)造函數(shù)邏輯
????????????//
????????}
????????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>
????????///?打開一個新的網(wǎng)頁,但不能設(shè)置網(wǎng)面的長寬
????????///?</summary>
????????///?<param?name="strUrl">地址</param>
????????///?<param?name="strPara">頁面參數(shù)</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();
????????}
????}
}
轉(zhuǎn)載于:https://www.cnblogs.com/sufei/archive/2011/06/22/2087365.html
總結(jié)
以上是生活随笔為你收集整理的JavascriptHelp的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 刚过去的三个月 电视机卖得太差了:首次低
- 下一篇: sql 时间函数