JavaScript - Change the Alert title - Asked By mostafa hamdy on 19-Jan-12 07:06 AM

Hello all
I have some javascript function which contains some alerts , and I want to set some title to this alert according to the alert message an time , how can I do that? please if any body get what I mean and can help me please send me or tell me about some URL may help me in doing that
smr replied to mostafa hamdy on 19-Jan-12 07:08 AM

no you can't.

Its a security/anti-phishing feature

smr replied to mostafa hamdy on 19-Jan-12 07:08 AM

The title of an alert box cannot be set. You could create a custom alert box, in reality it's just another page, and open it using, size the window and send your title and text in the querystring.


CustomAlert('Message Message, etc...', 'My Title');

Function CustomAlert(msg, title) {

 if (msg && title) {

  var win ='/path/to/box.aspx?msg=' + msg + '&title=' + title, 'alert box', 'toolbar,width=100px,height=200px');



look here for the available features (3rd param in

D Company replied to mostafa hamdy on 19-Jan-12 07:13 AM
Hello Friend,

Directly you cant edit alert window, to achieve your goal you can create your on message window

sample code on JS

function CONFIRM(){if (!confirm
("Change this to your message"))
history.go(-1);return " "}
<!-- END -->

dipa ahuja replied to mostafa hamdy on 19-Jan-12 07:14 AM

Using JavaScript simple alert box :

Page.RegisterClientScriptBlock("""<script>alert('Book Added');</script>");

Response.Write("<script>alert('Book Added')</script>");

Or you can display your own window by

using the modalpopupExtender:

CSS Effect


<style type="text/css">
















ModapPopUp Code


<cc1:ModalPopupExtender TargetControlID="Button2" BackgroundCssClass="modalBackground"

CancelControlID="btnMsg" PopupControlID="Panel1" PopupDragHandleControlID="btnMsg"

ID="ModalPopupExtender2" runat="server">


<asp:Panel ID="Panel1" runat="server" CssClass="ModalWindow">

<%--Button popup--%>


<table runat="server">


  <td bgcolor="#cccccc" style="border: 1px; border-color: Black;" height="20px" align="left"


  <div style="border-bottom-width: 1px; border: 1px solid">





  <td align="center" bgcolor="#99ccff">

  <br />

  The Record has been deleted!




<asp:Button ID="btnMsg" runat="server" Text="OK" /><br />



<asp:Button ID="Button2" runat="server" Text="OK" /><br />

mostafa hamdy replied to D Company on 19-Jan-12 07:32 AM
thanx Dear
but I couldnt understand what u mean may u give me more clarification please
Jitendra Faye replied to mostafa hamdy on 19-Jan-12 07:48 AM
You can't change the title  for alert window. but you can use your own popup control.

use jquery popup for this-

after adding jqueryui plugin you can use it.

like this-




funShow() {

$('#dialog).dialog({ resizable: false, height: 140, modal: true });





div id="dialog" title="Basic dialog">

  PUT YOur control here



asp:Button ID="Button1" runat="server" Text="Button" onClientClick="return funShow()" />

Note- This will be closed when you will click on close button,

Try this and let me know.