1

When I call window.prompt() in javascript and the first parameter (the message) is too large, the box doesn't get any larger. When the same thing happens with window.alert(), the box resizes accordingly. Is there some way to fix this or do I have to make my own prompt box, and if so, can I at least be pointed in the right direction of how that is done?

4

2 回答 2

1

There's no way to alter that behaviour. It's totally up to the browser to bring up the window.

One cannot show a native dialog (as alert() or prompt() do), instead, one has to imitate that behaviour in the space of the page's body. This would involve creating an overlay for a modal dialog and a simple absolutely-positioned container for the message.

于 2013-08-20T16:16:56.813 回答
0

您是否尝试过使用 JQuery UI 对话框?

http://jqueryui.com/dialog/#modal-form

HTML

<div id="dialog-form" title="Create new user">
<p>Text</p>

    <form>

    </form>
</div>

查询:

$( "#dialog-form" ).dialog({
  autoOpen: false,
  height: 300,
  width: 350,
  modal: true,
  buttons: {
    "Button": function() {
        //On click
    },
    Cancel: function() {
      $( this ).dialog( "close" ); //Close dialog
    }
  }
});
于 2013-08-20T16:19:28.277 回答