开发者

Changing JavaScript alert buttons

How do you change the words on the buttons in开发者_如何学编程 a javascript alert? I am new so the simplest way possible would be greatly appreciated.


You can't.

Instead, you can create a fake dialog in the DOM, using jQuery UI Dialog.


not possible, the browser sets that

what you could do is make a fake alert from elements,


You can overriede window.alert and have your own implemenation of it.

window.alert = function(msg, options){
     //Create the alert dialog box here using the default options and show the message.
}

You dont have to change your code in the application to use it.


Try something like this

    function CustomAlert(msg){
var customAlert = $("#customAlert");
      if(!customAlert.length){
        customAlert = $(document.body).append('<div id="customAlert"><div class="message">Msg></div><div><input class="button"     type="button" value="Ok" /></div></div>').hide();
}
customAlert.find("message").html(msg);

//Code to center the customAlert into view port along with faded background will go here

customAlert.find("input.button").unbind("click").click(function(){ 
 //Hide the customAlert goes here
 customAlert.hide();
});

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜