JQuery EasyUI的弹窗组件messager的几种使用方法
                                                                
                16-12-21 15:03
                字数 2220
                阅读 4982
                                已编辑
                                            
            JQuery EasyUi作为后台程序员必备的技能,今天介绍下EasyUi messager的几种用法
1、$.messager.alert(title, msg, icon, fn)
1.基本用法
<html xmlns="http://www.w3.org/1999/xhtml">    
<head runat="server">    
    <title>消息提示框</title>    
    <link href="/jquery-easyui-1.2.4/themes/default/easyui.css" rel="stylesheet" type="text/css" />    
    <link href="/jquery-easyui-1.2.4/themes/icon.css" rel="stylesheet" type="text/css" />    
    <script src="/jquery-easyui-1.2.4/jquery-1.6.4.min.js" type="text/javascript"></script>    
    <script src="/jquery-easyui-1.2.4/jquery.easyui.min.js" type="text/javascript"></script>    
    <script src="/jquery-easyui-1.2.4/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>    
    <script type="text/javascript">    
        $(function () {    
            $.messager.alert("操作提示", "操作成功!");    
        });    
    </script>    
</head>    
<body>    
</body>    
</html>    效果图:
 
  
2.icon使用
icon四种设置:"error"、"info"、"question"、"warning"  
<script type="text/javascript">    
    $(function () {    
        $.messager.alert("操作提示", "操作成功!","info");    
    });    
</script>     
  
<script type="text/javascript">    
    $(function () {    
        $.messager.alert("操作提示", "操作失败!","error");    
    });    
</script>    
  
<script type="text/javascript">    
    $(function () {    
        $.messager.alert("操作提示", "您确定要执行操作吗!","question");    
    });    
</script>     
  
<script type="text/javascript">    
    $(function () {    
        $.messager.alert("操作提示", "您确定要执行操作吗!","warning");    
    });    
</script>     
  
3.function使用
<script type="text/javascript">    
    $(function () {    
        $.messager.alert("操作提示", "操作成功!", "info", function () {    
            var i = 1;    
            alert(i);    
        });    
    });    
</script>    2、$.messager.confirm(title, msg, fn)
<script type="text/javascript">    
    $(function () {    
        $.messager.confirm("操作提示", "您确定要执行操作吗?", function (data) {    
            if (data) {    
                alert("确定");    
            }    
            else {    
                alert("取消");    
            }    
        });    
    });    
</script>     
  
3、$.messager.prompt(title, msg, fn)
<script type="text/javascript">    
    $(function () {    
        $.messager.confirm("操作提示", "您确定要执行操作吗?", function (data) {    
            if (data) {    
                alert("确定");    
            }    
            else {    
                alert("取消");    
            }    
        });    
    });    
</script>     
  
4、$.messager.show(options)
第一种方式
<html xmlns="http://www.w3.org/1999/xhtml">    
<head runat="server">    
    <title>消息提示框</title>    
    <link href="/jquery-easyui-1.2.4/themes/default/easyui.css" rel="stylesheet" type="text/css" />    
    <link href="/jquery-easyui-1.2.4/themes/icon.css" rel="stylesheet" type="text/css" />    
    <script src="/jquery-easyui-1.2.4/jquery-1.6.4.min.js" type="text/javascript"></script>    
    <script src="/jquery-easyui-1.2.4/jquery.easyui.min.js" type="text/javascript"></script>    
    <script src="/jquery-easyui-1.2.4/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>    
    <script type="text/javascript">    
        $(function () {    
            $.messager.show({    
                title: "操作提示",    
                msg: "请选择您要删除的记录!",    
                showType: 'slide',    
                timeout: 5000    
            });    
        });    
    </script>    
</head>    
<body>    
</body>    
</html>    第二种方式
<script type="text/javascript">    
    $(function () {    
        var options = {    
            title: "操作提示",    
            msg: "请选择您要删除的记录!",    
            showType: 'slide',    
            timeout: 5000    
        };    
        $.messager.show(options);    
    });    
</script>     
  
showType3种设置值:"show"、"slide"、"fade"
5、修改Button显示文字
<script type="text/javascript">    
    $(function () {    
        $.messager.defaults = { ok: "是", cancel: "否" };    
        $.messager.confirm("操作提示", "您确定要执行操作吗?", function (data) {    
            if (data) {    
                alert("是");    
            }    
            else {    
                alert("否");    
            }    
        });    
    });    
</script>     
  
6、方法
| 方法名 | 参数 | 描述 | 
|---|---|---|
| $.messager.show | options | 在屏幕的右下角显示一个消息窗口。这些选项的参数可以是一下的一个配置对象:showType:定义如何将显示消息窗口。可用的值是:null,slide,fade,show。默认值是slide。showSpeed:定义消息窗口完成的时间(以毫秒为单位), 默认值600;width:定义消息窗口的宽度。 默认值250。height:定义消息窗口的高度。 默认值100。msg:定义显示的消息文本。title:定义显示在标题面板显示的标题文本。timeout:如果定义为0,消息窗口将不会关闭,除非用户关闭它。如果定义为非0值,当超时后消息窗口将自动关闭。 | 
| $.messager.alert | title, msg, icon, fn | 显示一个警告窗口。参数如下:title:显示在标题面板的标题文本。msg:提示框显示的消息文本。icon:提示框显示的图标。可用的值是:error,question,info,warning.fn:当窗口关闭时触发的回调函数。 | 
| $.messager.confirm | title, msg, fn | 显示一个含有确定和取消按钮的确认消息窗口。参数如下:title:显示在标题面板的标题文本。msg:确认消息窗口显示的消息文本。fn(b):当用户点击按钮后触发的回调函数,如果点击OK则给回调函数传true,如果点击cancel则传false。 | 
| $.messager.prompt | title, msg, fn | 显示一个确定和取消按钮的信息提示窗口,提示用户输入一些文本。参数如下:title:显示在标题面板的标题文本。msg:提示窗口显示的消息文本。fn(val):用户点击按钮后的回调函,参数是用户输入的内容。 | 
> 转自 [http://www.cnblogs.com/libingql/archive/2011/07/17/2109020.html](http://www.cnblogs.com/libingql/archive/2011/07/17/2109020.html "http://www.cnblogs.com/libingql/archive/2011/07/17/2109020.html")
0人点赞>
                    请登录后发表评论
        
        相关推荐
        
    文章归档
    2025-09
                
                    1 篇
                
            
                    
                2025-08
                
                    7 篇
                
            
                    
                2025-07
                
                    1 篇
                
            
                    
                2025-05
                
                    2 篇
                
            
                    
                2024-11
                
                    1 篇
                
            
                                展开剩余 72 条
                            
                    2024-06
                    
                        1 篇
                    
                
                            
                    2024-05
                    
                        2 篇
                    
                
                            
                    2024-04
                    
                        2 篇
                    
                
                            
                    2024-03
                    
                        2 篇
                    
                
                            
                    2024-01
                    
                        1 篇
                    
                
                            
                    2023-10
                    
                        1 篇
                    
                
                            
                    2023-09
                    
                        1 篇
                    
                
                            
                    2023-08
                    
                        1 篇
                    
                
                            
                    2023-06
                    
                        1 篇
                    
                
                            
                    2023-04
                    
                        1 篇
                    
                
                            
                    2022-12
                    
                        2 篇
                    
                
                            
                    2022-06
                    
                        1 篇
                    
                
                            
                    2022-04
                    
                        4 篇
                    
                
                            
                    2022-03
                    
                        3 篇
                    
                
                            
                    2022-01
                    
                        6 篇
                    
                
                            
                    2021-12
                    
                        2 篇
                    
                
                            
                    2021-11
                    
                        2 篇
                    
                
                            
                    2021-10
                    
                        2 篇
                    
                
                            
                    2021-09
                    
                        1 篇
                    
                
                            
                    2021-08
                    
                        2 篇
                    
                
                            
                    2021-07
                    
                        4 篇
                    
                
                            
                    2021-06
                    
                        1 篇
                    
                
                            
                    2021-05
                    
                        3 篇
                    
                
                            
                    2021-04
                    
                        3 篇
                    
                
                            
                    2021-01
                    
                        2 篇
                    
                
                            
                    2020-11
                    
                        1 篇
                    
                
                            
                    2020-10
                    
                        3 篇
                    
                
                            
                    2020-09
                    
                        2 篇
                    
                
                            
                    2020-08
                    
                        1 篇
                    
                
                            
                    2020-07
                    
                        5 篇
                    
                
                            
                    2020-06
                    
                        5 篇
                    
                
                            
                    2020-05
                    
                        1 篇
                    
                
                            
                    2020-04
                    
                        1 篇
                    
                
                            
                    2020-03
                    
                        2 篇
                    
                
                            
                    2020-02
                    
                        3 篇
                    
                
                            
                    2020-01
                    
                        1 篇
                    
                
                            
                    2019-11
                    
                        5 篇
                    
                
                            
                    2019-10
                    
                        10 篇
                    
                
                            
                    2019-09
                    
                        12 篇
                    
                
                            
                    2019-08
                    
                        17 篇
                    
                
                            
                    2019-07
                    
                        8 篇
                    
                
                            
                    2019-05
                    
                        3 篇
                    
                
                            
                    2019-04
                    
                        8 篇
                    
                
                            
                    2019-03
                    
                        7 篇
                    
                
                            
                    2019-02
                    
                        8 篇
                    
                
                            
                    2019-01
                    
                        5 篇
                    
                
                            
                    2018-12
                    
                        7 篇
                    
                
                            
                    2018-11
                    
                        8 篇
                    
                
                            
                    2018-10
                    
                        4 篇
                    
                
                            
                    2018-09
                    
                        7 篇
                    
                
                            
                    2018-08
                    
                        12 篇
                    
                
                            
                    2018-07
                    
                        9 篇
                    
                
                            
                    2018-06
                    
                        6 篇
                    
                
                            
                    2018-05
                    
                        11 篇
                    
                
                            
                    2018-04
                    
                        18 篇
                    
                
                            
                    2018-03
                    
                        1 篇
                    
                
                            
                    2018-02
                    
                        2 篇
                    
                
                            
                    2018-01
                    
                        10 篇
                    
                
                            
                    2017-12
                    
                        14 篇
                    
                
                            
                    2017-11
                    
                        44 篇
                    
                
                            
                    2017-10
                    
                        13 篇
                    
                
                            
                    2017-09
                    
                        4 篇
                    
                
                            
                    2017-08
                    
                        12 篇
                    
                
                            
                    2017-07
                    
                        5 篇
                    
                
                            
                    2017-06
                    
                        4 篇
                    
                
                            
                    2017-05
                    
                        2 篇
                    
                
                            
                    2017-04
                    
                        3 篇
                    
                
                            
                    2017-03
                    
                        9 篇
                    
                
                            
                    2017-02
                    
                        3 篇
                    
                
                            
                    2017-01
                    
                        2 篇
                    
                
                            
                    2016-12
                    
                        10 篇
                    
                
                            
                    2016-11
                    
                        4 篇
                    
                
                        最新文章
        最受欢迎
    09-04 16:48
                    08-26 17:01
                    08-26 00:10
                    08-16 00:23
                    08-15 16:15
                    13 评论
                    11 评论
                    10 评论
                     
         
                 
                     
     
    
table表格显示有问题。