1

I am using the Javascript alert box:

function shareConfirm() {
    if(!confirm('Are you sure want to unshare?')) return false;
}

However, the title give the URL says and the alert box but I want to edit the title. It turns out javascript title can't be edited. So I best bet is to use jquery simple alert box with the same css as the custom javascript alert box. How can I do that?

pynovice
  • 7,424
  • 25
  • 69
  • 109
  • 1
    System alerts can't have the title edited you'll need a custom alert. http://labs.abeautifulsite.net/archived/jquery-alerts/demo/ – Rick Calder Mar 14 '13 at 10:06
  • 1
    You should see this post : http://stackoverflow.com/questions/43955/changing-the-default-title-of-confirm-in-javascript – vaugham Mar 14 '13 at 10:08

3 Answers3

1

Would you mind to use jQueryUI ? Then solving your problem will be easy as butter :)

Step 1: Include jQueryUI in ur page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Step 2: Create a div. The text in this div will display as alert. You need to hide this div in $(document).ready()

<div id='myAlertbox'></div>

Step 3: Here you go:

$("#myAlertbox").html('Are you sure want to unshare?');
$("#myAlertbox").dialog({
    title: "yourRequiredTitleHere",
modal: true,
buttons : [{
    text : "Ok",
    click : function() {
            $(this).dialog("close");
            //You can do whatever you want here.
    }
    }],
});
codeVerine
  • 742
  • 3
  • 14
0

This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window.

-1

the style of confirm() and alert() boxes depend on the browser and operating system. therefore it will be a nearly impossible to create a css for jquery alert boxes to match each browser/os combination

mfo
  • 152
  • 4