如何显示三个按钮确认警报“是”“否”和“取消”,因为它表明在MS Word [英] how to show confirmation alert with three buttons 'Yes' 'No' and 'Cancel' as it shows in MS Word

查看:152
本文介绍了如何显示三个按钮确认警报“是”“否”和“取消”,因为它表明在MS Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我展示通过JavaScript确认对话框:

I'm showing a confirmation alert box through JavaScript:

function checked() {
 if (hdnval.toLowerCase() != textbox1.toLowerCase()) {
  var save = window.confirm('valid')
   if (save == true) 
   {
     return true;
   }
   else
    {
      return false;
    }
 }
}

确认警报显示有两个按钮:确定和取消

The confirmation alert is showing with two buttons: OK and Cancel.

我想告诉我的确认警告第三个按钮。我想这三个按钮是这样的:是否,取消,因为它显示了在MS Word

I want to show a third button in my confirmation alert. I want the three buttons to be like this: 'Yes' 'No' 'Cancel', as it shows in MS Word.

推荐答案

这不能与本地JavaScript对话框中完成的,但很多JavaScript库,包括更灵活的对话。您可以使用像 jQuery用户界面的对话框对话框这一点。

This cannot be done with the native javascript dialog box, but a lot of javascript libraries include more flexible dialogs. You can use something like jQuery UI's dialog box for this.

也看到这些非常类似的问题:

See also these very similar questions:

  • JavaScript Confirm boxes with custom buttons
  • custom choices in javascript confirm dialog

下面是一个例子,这表现在本的jsfiddle

Here's an example, as demonstrated in this jsFiddle:

<html><head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/normalize.css">
    <link rel="stylesheet" type="text/css" href="/css/result-light.css">
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css">
</head>
<body>
    <a class="checked" href="http://www.google.com">Click here</a>
    <script type="text/javascript">

        $(function() {
            $('.checked').click(function(e) {
                e.preventDefault();
                var dialog = $('<p>Are you sure?</p>').dialog({
                    buttons: {
                        "Yes": function() {alert('you chose yes');},
                        "No":  function() {alert('you chose no');},
                        "Cancel":  function() {
                            alert('you chose cancel');
                            dialog.dialog('close');
                        }
                    }
                });
            });
        });

    </script>
</body><html>

这篇关于如何显示三个按钮确认警报“是”“否”和“取消”,因为它表明在MS Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆