faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 20 people (60%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How Can I Create Message Boxes with different Icons (Exclamation,Information,Error) and buttons ?

Apr 8th, 2008 18:09
ha mo, Abolfazl Shirazi, Abolfazl Shirazi


Abolfazl Shirazi :
Recently I found my answer myself. We should use activex to solve this 
problem.
Try it :
<html>
<head>
<script language="javascript">
function ShowMSG() {
	WSHShell = new ActiveXObject("WScript.Shell")
	q1 = "Javascript Message Boxes is Cool !" // Message
	q2 = "My Favorite Title" // Title
	q3 = 64 // Icon Numer
	q4 = 2 // Buttons Numer
    intDoIt =  WSHShell.Popup(q1,3,q2,q3+q4);
    switch(intDoIt) {
    	case 1 : alert("You Pressed Ok") ; break
    	case 2 : alert("You Pressed Cancel") ; break
    	case 3 : alert("You Pressed Abort") ; break
    	case 4 : alert("You Pressed Retry") ; break
    	case 5 : alert("You Pressed Ignore") ; break
    	case 6 : alert("You Pressed Yes") ; break
    	case 7 : alert("You Pressed No") ; break
    }
}
</script>
</head>
	<body>
		<button onclick="ShowMSG()">Show Message</button>
		<h3>The Buttons :</h3>
		<p><font size="2" face="Verdana, Arial, Helvetica, 
sans-serif"><b>Ok : 0<br>
				</b></font><font size="2" 
face="Verdana, Arial, Helvetica, sans-serif"><b>Ok Cancel : 
1</b></font><br>
			<font size="2" face="Verdana, Arial, 
Helvetica, sans-serif"><b>Abort Retry Ignore : 2</b></font><br>
			<font size="2" face="Verdana, Arial, 
Helvetica, sans-serif"><b>Yes No Cancel : 3</b></font><br>
			<font size="2" face="Verdana, Arial, 
Helvetica, sans-serif"><b>Yes No : 4</b></font><br>
			<font size="2" face="Verdana, Arial, 
Helvetica, sans-serif"><b>Retry Cancel : 5</b></font><br>
		</p>
		<h3>The Icons :</h3>
		<p><b><font size="2" face="Verdana, Arial, Helvetica, 
sans-serif">Critical : 16</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Question : 32</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Exclamation : 48</font><font 
size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Information : 64</font><font 
size="2"><br>
				</font></b></p>
		<h3>Returning Values :</h3>
		<p><b><font size="2" face="Verdana, Arial, Helvetica, 
sans-serif">Ok : 1</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Cancel : 2</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Abort : 3</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Retry : 4</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Ignore : 5</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">Yes : 6</font><font size="2"><br>
				</font><font size="2" face="Verdana, 
Arial, Helvetica, sans-serif">No : 7</font><font size="2"><br>
				</font></b></p>
	</body>
</html>
Enjoy It Friends !!!
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com