zoukankan      html  css  js  c++  java
  • 常用的Js类

        ClientScript.RegisterStartupScript(this.GetType(), "no", JS.Alert(strErrMsg));

    Code
    Code
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace RM.Common
    {
        
    public class JS
        {
            
    private static string strJsHead = "<script language=\"javascript\">";
            
    private static string strJsFoot = "</script>";

            
    #region Alert:弹出消息框.
            
    /// <summary>
            
    /// 弹出消息框.
            
    /// </summary>
            
    /// <param name="msg">消息内容.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Alert(string msg)
            {
                
    string strJs = strJsHead + "alert(\"" + msg + "\");" + strJsFoot;
                
    return strJs;
            }

            
    /// <summary>
            
    /// 弹出消息框.
            
    /// </summary>
            
    /// <param name="msg">消息内容.</param>
            
    /// <param name="url">要跳转的Url.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Alert(string msg, string url)
            {
                
    string strJs = strJsHead + "alert(\"" + msg + "\");document.location=\"" + url + "\";" + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region Back:浏览器历史记录后退.
            
    /// <summary>
            
    /// 浏览器历史记录后退.
            
    /// </summary>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Back()
            {
                
    string strJs = strJsHead + "history.back(1);" + strJsFoot;
                
    return strJs;
            }

            
    /// <summary>
            
    /// 后退.
            
    /// </summary>
            
    /// <param name="step">后退的步数.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Back(int step)
            {
                
    string strJs = strJsHead + "history.back(" + step + ");" + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region Go:浏览器历史记录前进或后退.
            
    /// <summary>
            
    /// 浏览器历史记录前进或后退.
            
    /// </summary>
            
    /// <param name="step"></param>
            
    /// <returns></returns>
            public static string Go(int step)
            {
                
    string strJs = strJsHead + "history.go(" + step + ")" + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region Redirect:跳转到指定的URL.
            
    /// <summary>
            
    /// 跳转到指定的URL.
            
    /// </summary>
            
    /// <param name="sUrl">要跳转到的URL地址.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Redirect(string sUrl)
            {
                
    string strJs = "document.location=\"" + sUrl + "\";";
                strJs 
    = strJsHead + strJs + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region Replace:改变当前页面的URL.
            
    /// <summary>
            
    /// 改变当前页面的URL.
            
    /// </summary>
            
    /// <param name="sUrl">改变后的URL地址.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Replace(string sUrl)
            {
                
    string strJs = "document.location.replace(\"" + sUrl + "\");";
                strJs 
    = strJsHead + strJs + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region CloseWindow:关闭当前浏览器窗口.
            
    /// <summary>
            
    /// 关闭当前浏览器窗口.
            
    /// </summary>
            
    /// <returns>包含script标签的字符.</returns>
            public static string CloseWindow()
            {
                
    string strJs = strJsHead + "window.close();" + strJsFoot;
                
    return strJs;
            }
            
    #endregion

            
    #region RegJs:为自定义的JS加上script标签.
            
    /// <summary>
            
    /// 为自定义的JS加上script标签.
            
    /// </summary>
            
    /// <param name="strJs">自定义的JS.</param>
            
    /// <returns>包含script标签的字符.</returns>
            public static string RegJs(string strJs)
            {
                
    string qdkRe = strJsHead + strJs + strJsFoot;
                
    return qdkRe;
            }
            
    #endregion

            
    #region Reload:重新载入当前页面.
            
    /// <summary>
            
    /// 重新载入当前页面.
            
    /// </summary>
            
    /// <returns>包含script标签的字符.</returns>
            public static string Reload()
            {
                
    string strJs = "document.location=self.location;";
                strJs 
    = strJsHead + strJs + strJsFoot;
                
    return strJs;
            }
            
    #endregion

        }
    }
  • 相关阅读:
    !clrstack未显示任何方法名
    !dumpheap参数和SOS帮助系统的一些一般信息
    WinDbg Script---显示RCW对象引用的COM对象
    为什么不能将2个调试器附加到1个进程
    什么是互操作调试(Interop-Debugging)?
    为什么托管调试与本机调试不同?
    在WinDBG中管理源代码窗口
    如何从转储文件确定 /LARGEADDRESSAWARE
    Dump文件数据存储格式(九)
    Windbg命令系列---!cpuid(CPU信息)
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/1459031.html
Copyright © 2011-2022 走看看