3

How do i place the alert box at the center of the browser and is it possible to change the "Javascript" text in the alert box to something like "Page Reloading"

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

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

extraRice
  • 323
  • 2
  • 17
  • 1
    To center the alert : no . never. don't count on it. though it should be centered , javascript title : also.http://stackoverflow.com/questions/43955/changing-the-default-title-of-confirm-in-javascript – Royi Namir Oct 05 '13 at 17:40

1 Answers1

1

you can use jQuery UI dialog widget...

$(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

Psych Half
  • 1,393
  • 1
  • 11
  • 22