zoukankan      html  css  js  c++  java
  • JavascriptHelp

     
    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();
            }
        }
    }
    本人的博客不再维护从2013年就不再维护了 需要我帮助的朋友请到我的个人论坛 http://www.sufeinet.com 进行讨论,感谢大家对我的支持!
  • 相关阅读:
    第三章 函数式编程中的异常处理
    第二章 函数式数据结构
    android 轮播图
    模仿qq列表信息滑动删除效果
    android绘制圆形图片的两种方式
    android图片验证码--自绘控件
    MPAndroidChart 3.0——LineChart(折线图)
    提交本地项目到github服务器
    android 帧动画,补间动画,属性动画的简单总结
    android AsynTask处理返回数据和AsynTask使用get,post请求
  • 原文地址:https://www.cnblogs.com/sufei/p/2087365.html
Copyright © 2011-2022 走看看