zoukankan      html  css  js  c++  java
  • 网页弹出提示框的几种方法.


    1. 在js里面 使用 alert("您的消息")

    2. 在后台代码里面输出js脚本
       button1.Attributes.Add("onclick", "return confirm('确定删除吗?');");

    3. 在后台代码里面:

        Response.Write("<script language=javascript>window.alert('" + ls_ts+ "');</script>"); //显示提示框

    4. Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>window.alert('ff');</script>");


    如果页面中使用了Ajax ,则上述代码即使执行也无效果。应对这种情况我们通常采用:
    ScriptManager.RegisterStartupScript(this.Button1, this.GetType(), "alertScript", "window.alert('ff')", true);
    或者
    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "alertScript", "window.alert('ff')", true);
    其中第一个参数为要注册脚本的控件ID,试了一下,只要是本页面的就行。
    第二个参数为注册脚本控件类型,是控件还是this的GetType()都可以,typeOf(string)也没问题.
    第三个脚本函数的名字,随便起。
    第四个是脚本内容。
    第五个是标明是否再添加脚本标签,如果第四个参数里包含了<script></script>标签,此处则为false,否则为true。


      

    5.  //如果 页面上使用了 UpdatePanel

      ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", "alert('yyyyy')", true);

       注解: message 是您要弹出的信息

  • 相关阅读:
    埋点
    go 搭建web服务
    go的常见操作
    Zeus资源调度系统介绍
    支付系统中热点账户的性能问题
    redis
    集成Spring-Boot与gRPC,grpc-spring-boot-starter
    Spring Cloud灰度发布之Nepxion Discovery
    Spring Cloud Stream
    通过消息总线Spring Cloud Bus实现配置文件刷新(使用Kafka或RocketMQ)
  • 原文地址:https://www.cnblogs.com/zhwl/p/1965705.html
Copyright © 2011-2022 走看看