Solved

Giving title for JavaScript Alert message

Posted on 2004-09-14
6
333 Views
Last Modified: 2010-05-18
Hi All...
           Can anyone help me on this issue. I m working on JavaScript and in case of JavaScript alert messages its title is shown as "Microsoft Internet Explorer" as I m using IE5 as my browser. I want to give my own title in the alert meassage. Is it possible?? If yes then write me how. Waiting for your reply..

Shamakant Sharma.
Sr. Programmer
Path Infotech Ltd.

0
Comment
Question by:shamakant_sharma
  • 4
6 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 12053125
You can't.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12053130
//iE soln only, use vbscript
<HTML>
<script language = VBScript>
Sub alert(title, content)
     MsgBox content, 0, title
End Sub
</script>
<body>
     <input type = button value = "Click " onClick = "alert 'My title', 'Hello World'">
</body>
</HTML>
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12053156
0
 
LVL 33

Accepted Solution

by:
sajuks earned 125 total points
ID: 12053165
//create your own ( credit to mplungjan )
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!-- //
function fakeAlert(cMsg,cTitle,cImg) {
alertOptions="screenX=500,screenY=400,top=400,left=500,height=100,width=200,hotkeys=no"

newWin=window.open("","fakeAlertWindow",alertOptions)
newDoc=newWin.document
newDoc.write('<ht'+'ml><he'+'ad><tit'+'le>'+cTitle+'</tit'+'le></he'+'ad><bo'+'dy bgColor="silver" onLoad="document.forms[0].elements[0].focus()">');
newDoc.write('<table><tr><td><img src="'+cImg+'" width=34 height=34 alt="" border=0></td>');
newDoc.write('<td><font size="-1">'+cMsg+'</font></td></tr>');
newDoc.write('<tr><td colspan=2 align="Center">');
newDoc.write('<form><input type="button" value="OK" onClick="window.close();"></form>');
newDoc.write('</td></tr></table></bo'+'dy></ht'+'ml>');
}
//-->
</script>
</head>
<body>
Fake alert box.
<form name="frmMain">
<input type="button" value="Click Me" onClick="fakeAlert('This is a fake alert box.','Alert title','icon2tr.gif')">
</form>
</body>
</html>
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now