How to edit a JavaScript alert box title?

前端 未结 11 2258
执笔经年
执笔经年 2020-11-22 10:15

I\'m generating a JavaScript alert with following code in C# .NET page:

Response.Write(\"

        
相关标签:
11条回答
  • 2020-11-22 10:37

    You can do a little adjustment to leave a blank line at the top.

    Like this.

            <script type="text/javascript" >
                alert("USER NOTICE "  +"\n"
                +"\n"
                +"New users are not allowed to work " +"\n"
                +"with that feature.");
            </script>
    
    0 讨论(0)
  • 2020-11-22 10:40

    I had a similar issue when I wanted to change the box title and button title of the default confirm box. I have gone for the Jquery Ui dialog plugin http://jqueryui.com/dialog/#modal-confirmation

    When I had the following:

    function testConfirm() {
      if (confirm("Are you sure you want to delete?")) {
        //some stuff
      }
    }
    

    I have changed it to:

    function testConfirm() {
    
      var $dialog = $('<div></div>')
        .html("Are you sure you want to delete?")
        .dialog({
          resizable: false,
          title: "Confirm Deletion",
          modal: true,
          buttons: {
            Cancel: function() {
              $(this).dialog("close");
            },
            "Delete": function() {
              //some stuff
              $(this).dialog("close");
            }
          }
        });
    
      $dialog.dialog('open');
    }
    

    Can be seen working here https://jsfiddle.net/5aua4wss/2/

    Hope that helps.

    0 讨论(0)
  • 2020-11-22 10:42

    Yes you can change it. if you call VBscript function within Javascript.

    Here is simple example

    <script>
    
    function alert_confirm(){
    
          customMsgBox("This is my title","how are you?",64,0,0,0);
    }
    
    </script>
    
    
    <script language="VBScript">
    
    Function customMsgBox(tit,mess,icon,buts,defs,mode)
       butVal = icon + buts + defs + mode
       customMsgBox= MsgBox(mess,butVal,tit)
    End Function
    
    </script>
    
    <html>
    
    <body>
    <a href="javascript:alert_confirm()">Alert</a>
    </body>
    
    </html>
    
    0 讨论(0)
  • 2020-11-22 10:43

    I Found this Sweetalert for customize header box javascript.

    For example

    swal({
      title: "Are you sure?",
      text: "You will not be able to recover this imaginary file!",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes, delete it!",
      closeOnConfirm: false
    },
    function(){
      swal("Deleted!", "Your imaginary file has been deleted.", "success");
    });
    
    0 讨论(0)
  • 2020-11-22 10:46

    You can do this in IE:

    <script language="VBScript">
    Sub myAlert(title, content)
          MsgBox content, 0, title
    End Sub
    </script>
    
    <script type="text/javascript">
    myAlert("My custom title", "Some content");
    </script>
    

    (Although, I really wish you couldn't.)

    0 讨论(0)
提交回复
热议问题