简体   繁体   English

我想在JavaScript的“确认”对话框中显示一条消息,而不使用html或其他任何消息

[英]I want to display a message in confirm dialog in javascript without using html or any other

I want to display a message "Do you want to delete?" 我想显示一条消息“您要删除吗?” in confirm dialog. 在确认对话框中。

I had given that message in the data content, but it is not working. 我已经在数据内容中给出了该消息,但是它不起作用。

How can i do this only by using javascript ? 我如何只能通过使用javascript来做到这一点?

Here is my code : 这是我的代码:

function confirmDelete ( a )
{   
$(function() {

    $( "#dialog-confirm" ).dialog({
      data : "Do you want to delete?",
      resizable: false,
      height:140,
      modal: true,
      buttons: {
        "YES": function() {
            $(this).load("./removeAgent.action?id="+a,  function() {
                $("#agentResult").trigger("reloadGrid");
            });
            $(this).dialog("close");
        },
        "   NO    ": function() {
            $(this).dialog("close");
        }
      }
    });
});

} }

You can do this by using confirm method in javascript itself. 您可以使用javascript本身中的Confirm方法来执行此操作。

The html part html部分

Click the button to display a confirm box. 单击按钮以显示一个确认框。

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

The JavaScript Part JavaScript部分

<script>
    function myFunction(){
    var x;
    var r=confirm("Press a button!");
    if (r==true){
      x="You pressed OK!";
      }
    else{
      x="You pressed Cancel!";
      }
    document.getElementById("demo").innerHTML=x;
    }
</script>

Or 要么

If you want to use jquery plugins Lokk at the links below. 如果您想使用jquery插件,请访问下面的链接。

http://jquery-plugins.net/tag/confirm-box http://jquery-plugins.net/tag/confirm-box

http://fabien-d.github.io/alertify.js/0.4.0rc1/ http://fabien-d.github.io/alertify.js/0.4.0rc1/

Try this method in onClick listener, 在onClick侦听器中尝试此方法,

    <script>
        function clickAction()
{
        var result;
        var buttonpressed=confirm("Button Press");
        if (buttonpressed==true)
{
          result="OK";
          }
        else
{
          result="Cancel";
          }
        document.getElementById("demo").innerHTML=result;
        }
    </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想使用AddResource调用javascript确认对话框 - I want to call javascript confirm dialog using AddResource 我想显示一条消息以确认删除 - I want to display a message to confirm the delete Ajax / Javascript删除无对话框的确认文本 - Ajax/Javascript Delete Confirm Text Without Dialog 如何在JavaScript Confirm()对话框中获取HTML链接? - How to get an HTML link in a javascript confirm() dialog? 如何使用JavaScript在特定HTML div中显示消息? - How do I display message in a particular HTML div using JavaScript? 尝试在确认消息中显示变量值:Javascript - Trying to display variable value in confirm message: Javascript 消息/确认对话框 - Message / confirm dialog 使用 HTML 和 JavaScript 的确认方法 - Confirm method using HTML and JavaScript 使用纯 javascript 和引导程序:如何显示模式对话框确认来自 JSON API 的提取操作的响应 - Using pure javascript and Bootstrap : How to display a modal dialog confirm response from fetch operation from JSON API 我如何避免Firefox确认消息“要显示此页面,Firefox必须发送将重复任何操作的信息”? - How do i avoid the firefox confirm message “to display this page firefox must send information that will repeat any action”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM