Ext.window.MessageBox

1、修改默认的按钮文字

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ext.MessageBox.show</title>
    <link href="ext-4.0.7-gpl/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    <script src="ext-4.0.7-gpl/bootstrap.js" type="text/javascript"></script>
    <script type="text/javascript">
        Ext.onReady(function () {
            // OK
            Ext.MessageBox.msgButtons[0].setText("按钮一");
            // YES
            Ext.MessageBox.msgButtons[1].setText("按钮二");
            // NO
            Ext.MessageBox.msgButtons[2].setText("按钮三");
            // CANCEL
            Ext.MessageBox.msgButtons[3].setText("按钮四");

            Ext.MessageBox.show({
                title: "提示",
                msg: "自定义按钮文字",
                modal: true,
                buttons: Ext.Msg.YESNOCANCEL
            });
        });
    </script>
</head>
<body>
</body>
</html>

效果图:

2、动态更新提示框

  调用格式:

  updateText([String text])

  参数说明:

  [String text]:显示的消息内容,为可选参数

  返回值:

  Ext.window.MessageBox

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>动态更新消息文字</title>
    <link href="ext-4.0.7-gpl/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    <script src="ext-4.0.7-gpl/bootstrap.js" type="text/javascript"></script>
    <script type="text/javascript">
        Ext.onReady(function () {
            var msgBox = Ext.MessageBox.show({
                title: "提示",
                msg: "动态更新消息文字",
                modal: true,
                buttons: Ext.MessageBox.OK,
                fn: function () {
                    Ext.TaskManager.stop(task);
                }
            });

            // Ext.TaskManager是一个功能类,用来定时执行程序
            var task = {
                run: function () {
                    msgBox.updateText("当前时间:" + Ext.util.Format.date(new Date(), "Y-m-d g:i:s A"));
                },
                interval: 1000
            };

            Ext.TaskManager.start(task);
        });
    </script>
</head>
<body>
</body>
</html>

效果图:

原文地址:https://www.cnblogs.com/libingql/p/2459148.html