【问题标题】:Center alertbox and change 'Javascript' text in the alertbox居中警报框并更改警报框中的“Javascript”文本
【发布时间】:2013-10-05 17:37:31
【问题描述】:

如何将警告框放置在浏览器的中心,是否可以将警告框中的“Javascript”文本更改为“页面重新加载”之类的内容

$('#reload').click(function(e) {
   if (confirm('Are you sure')) window.location.reload()
});

http://jsfiddle.net/wvNrC/1/

【问题讨论】:

  • 使警报居中:否。绝不。不要指望它。虽然它应该居中,但 javascript 标题:also.*.com/questions/43955/…

标签: javascript google-chrome


【解决方案1】:

您可以使用 jQuery UI 对话框小部件...

$(document).ready(function () {

  $("#dialog").dialog({
    modal: true,
    bgiframe: true,
    width: 500,
    height: 200,
    autoOpen: false
  });

  $("#reload").click(function (e) {
    e.preventDefault();

    $("#dialog").dialog('option', 'buttons', {
      "Confirm": function () {
        window.location.reload();
      },
      "Cancel": function () {
        $(this).dialog("close");
      }
    });

    $("#dialog").dialog("open");

  });

});

js fiddle

【讨论】: