Title of a JavaScript Alert Box

How do you chang the title of a javascript alert box?

scottymac
samacdonaldAsked:
Who is Participating?
 
HolySpiritConnect With a Mentor Commented:
samacdonald,
U can try this VBScript to change the title of the alert box since JavaScript cannot do this :

<HTML>
<script language = VBScript>
Sub alert(title, content)
      MsgBox content, 0, title
End Sub
</script>
<body>
      <input type = button value = "Click me" onClick = "alert 'Here is the title', 'Here is the content'">
</body>
</HTML>

<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
Can this script solve your problem?
<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>

-- Holy Spirit
0
 
maneshrCommented:
you cannot change a title of a javascript alert box. i think that this is due to security reasons. otherwise anyone can mimic system message boxes and get inputs from the user!!

0
 
sthungCommented:
This is no way to change the javascript alert, prompt, confirm dialog box title because of the implementation of netsacpe and Internet Explorer is different. And the javascript standard doesn't provide that feature.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
knightEknightCommented:
That might work in IE only.
The other option is just to define your own alert:

<SCRIPT langauge='javascript'>
function myalert(title,msg)
{
   var mypopup = window.open("",title,width=300,height=200);
   mypopup.document.open();
   mypopup.document.writeln("<HTML><BODY><FORM><CENTER>");
   mypopup.document.writeln(msg);
   mypopup.document.writeln("<INPUT type='button' value='OK' onClick='self.close();'>");
   mypopup.document.writeln("</center></form></body></html>");
   mypopup.document.close();
}

....

<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">
0
 
knightEknightCommented:
typo on my first line up there... should be:

  var mypopup = window.open("",title,"width=300,height=200");
0
 
knightEknightCommented:
Come to think of it, I forgot the title part altogether!

<SCRIPT langauge='javascript'>
function myalert(title,msg)
{
   var mypopup = window.open("",title,"width=300,height=200");
   mypopup.document.open();
   mypopup.document.writeln("<HTML><HEAD><TITLE>"+title+"</title></head>");
   mypopup.document.writeln("<BODY><FORM><CENTER>");
   mypopup.document.writeln(msg);
   mypopup.document.writeln("<INPUT type='button' value='OK' onClick='self.close();'>");
   mypopup.document.writeln("</center></form></body></html>");
   mypopup.document.close();
}
</script>
....
<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">
0
All Courses

From novice to tech pro — start learning today.