?
Solved

Giving title for JavaScript Alert message

Posted on 2004-09-14
6
Medium Priority
?
362 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
4 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

829 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