samacdonald
asked on
Title of a JavaScript Alert Box
How do you chang the title of a javascript alert box?
scottymac
scottymac
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!!
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,heigh t=200);
mypopup.document.open();
mypopup.document.writeln(" <HTML><BOD Y><FORM><C ENTER>");
mypopup.document.writeln(m sg);
mypopup.document.writeln(" <INPUT type='button' value='OK' onClick='self.close();'>") ;
mypopup.document.writeln(" </center>< /form></bo dy></html> ");
mypopup.document.close();
}
....
<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">
The other option is just to define your own alert:
<SCRIPT langauge='javascript'>
function myalert(title,msg)
{
var mypopup = window.open("",title,width
mypopup.document.open();
mypopup.document.writeln("
mypopup.document.writeln(m
mypopup.document.writeln("
mypopup.document.writeln("
mypopup.document.close();
}
....
<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">
typo on my first line up there... should be:
var mypopup = window.open("",title,"widt h=300,heig ht=200");
var mypopup = window.open("",title,"widt
Come to think of it, I forgot the title part altogether!
<SCRIPT langauge='javascript'>
function myalert(title,msg)
{
var mypopup = window.open("",title,"widt h=300,heig ht=200");
mypopup.document.open();
mypopup.document.writeln(" <HTML><HEA D><TITLE>" +title+"</ title></he ad>");
mypopup.document.writeln(" <BODY><FOR M><CENTER> ");
mypopup.document.writeln(m sg);
mypopup.document.writeln(" <INPUT type='button' value='OK' onClick='self.close();'>") ;
mypopup.document.writeln(" </center>< /form></bo dy></html> ");
mypopup.document.close();
}
</script>
....
<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">
<SCRIPT langauge='javascript'>
function myalert(title,msg)
{
var mypopup = window.open("",title,"widt
mypopup.document.open();
mypopup.document.writeln("
mypopup.document.writeln("
mypopup.document.writeln(m
mypopup.document.writeln("
mypopup.document.writeln("
mypopup.document.close();
}
</script>
....
<input type="button" value="Click Me" onClick="myalert('Here is the title', 'Here is the content');">