zoukankan      html  css  js  c++  java
  • [功能帮助类] JsHelper--Javascript操作帮助类 (转载)

    点击下载 JsHelper.rar

    这个类是关于加密,解密的操作,文件的一些高级操作
    1.Javascript弹出信息,并跳转指定页面。 
    2.Javascript弹出信息,并返回历史页面
    3.Javascript直接跳转到指定的页面
    4.Javascript弹出信息 并指定到父窗口
    5.Javascript返回到父窗口
    6.Javascript返回历史页面
    7.Javascript弹出信息 
    8.Javascript注册脚本块
    看下面代码吧

    /// <summary>
    /// 类说明:Assistant
    /// 编 码 人:苏飞
    /// 联系方式:361983679  
    /// 更新网站:[url=http://www.cckan.net/thread-655-1-1.html]http://www.cckan.net/thread-655-1-1.html[/url]
    /// </summary>
    using System.Web;
     
    namespace DotNet.Utilities
    {
        /// <summary>
        /// 客户端脚本输出
        /// </summary>
        public class JsHelper
        {
            /// <summary>
            /// 弹出信息,并跳转指定页面。
            /// </summary>
            public static void AlertAndRedirect(string message, string toURL)
            {
                string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
                HttpContext.Current.Response.Write(string.Format(js, message, toURL));
                HttpContext.Current.Response.End();
            }
     
            /// <summary>
            /// 弹出信息,并返回历史页面
            /// </summary>
            public static void AlertAndGoHistory(string message, int value)
            {
                string js = @"<Script language='JavaScript'>alert('{0}');history.go({1});</Script>";
                HttpContext.Current.Response.Write(string.Format(js, message, value));
                HttpContext.Current.Response.End();
            }
     
            /// <summary>
            /// 直接跳转到指定的页面
            /// </summary>
            public static void Redirect(string toUrl)
            {
                string js = @"<script language=javascript>window.location.replace('{0}')</script>";
                HttpContext.Current.Response.Write(string.Format(js, toUrl));
            }
     
            /// <summary>
            /// 弹出信息 并指定到父窗口
            /// </summary>
            public static void AlertAndParentUrl(string message, string toURL)
            {
                string js = "<script language=javascript>alert('{0}');window.top.location.replace('{1}')</script>";
                HttpContext.Current.Response.Write(string.Format(js, message, toURL));
            }
     
            /// <summary>
            /// 返回到父窗口
            /// </summary>
            public static void ParentRedirect(string ToUrl)
            {
                string js = "<script language=javascript>window.top.location.replace('{0}')</script>";
                HttpContext.Current.Response.Write(string.Format(js, ToUrl));
            }
     
            /// <summary>
            /// 返回历史页面
            /// </summary>
            public static void BackHistory(int value)
            {
                string js = @"<Script language='JavaScript'>history.go({0});</Script>";
                HttpContext.Current.Response.Write(string.Format(js, value));
                HttpContext.Current.Response.End();
            }
     
            /// <summary>
            /// 弹出信息
            /// </summary>
            public static void Alert(string message)
            {
                string js = "<script language=javascript>alert('{0}');</script>";
                HttpContext.Current.Response.Write(string.Format(js, message));
            }
     
            /// <summary>
            /// 注册脚本块
            /// </summary>
            public static void RegisterScriptBlock(System.Web.UI.Page page, string _ScriptString)
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), "scriptblock", "<script type='text/javascript'>" + _ScriptString + "</script>");
            }
        }
    }
  • 相关阅读:
    如何在Docker中部署一个可以被外部访问的Apollo配置中心
    ELK+Filebeat日志中心搭建(一)——ElasticSearch7.3.1安装
    零基础配置Hadoop集群——Ambari安装及配置详解
    【转】CSS中position属性( absolute | relative | static | fixed )详解
    浅谈JavaScript中的call和apply
    js 获取某年的某天是第几周
    IE回车的怪异行为
    面向对象的三大特性
    错误175:指定的存储区提供程序在配置中找不到,或者无效 一些感想
    postgresql12.5 windows版安装
  • 原文地址:https://www.cnblogs.com/lizeyan/p/3628631.html
Copyright © 2011-2022 走看看