How to edit a JavaScript alert box title?

前端 未结 11 2367
执笔经年
执笔经年 2020-11-22 10:15

I\'m generating a JavaScript alert with following code in C# .NET page:

Response.Write(\"

        
11条回答
  •  余生分开走
    2020-11-22 10:31

    Override the javascript window.alert() function.

    window.alert = function(title, message){
        var myElementToShow = document.getElementById("someElementId");
        myElementToShow.innerHTML = title + "
    " + message; }

    With this you can create your own alert() function. Create a new 'cool' looking dialog (from some div elements).

    Tested working in chrome and webkit, not sure of others.

提交回复
热议问题