<HTML><HEAD>
<!--
--------------------------------------------------
Hello World #5: Saying Hello with a Confirm Dialog
--------------------------------------------------
-->
<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers
/*
THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
Copyright (c)1998 by Charles River Media. All Rights Reserved.
This applet can only be re-used or modifed by license holders of the
JavaScript Cookbook CD-ROM. Credit must be given in the source
code and this copyright notice must be maintained. If you do
not hold a license to the JavaScript Cookbook, you may NOT
duplicate or modify this code for your own use.
Use at your own risk. No warranty is given or implied of the suitability
of this applet for any specific application. Neither Erica Sadun nor
Charles River Media will be held responsible for any unwanted effects
due to the use of this applet or any derivative.
*/
function shall_I_Alert()
{
if (confirm("Say Hello?"))
alert("Hello World!")
}
<!-- done hiding --></SCRIPT></HEAD>
<BODY bgcolor="ffffff">
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Communications 105</H1></FONT>
<BLOCKQUOTE>
<FONT COLOR="770000">
After the reader presses the below button, I'll ask
if he wants to say hello. If he agrees, I'll say hello
with an alert.
</FONT>
<FORM>
<INPUT
TYPE="button"
VALUE=" Say Hello World to the Reader? "
onClick="shall_I_Alert()"
>
</FORM>
</BLOCKQUOTE>
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>
This fifth "hello" program uses the confirm
dialog to check if the reader wishes a greeting.
<h3>Using Confirm</h3>
<font color="770000" size=3><pre><null
>if (confirm("Say Hello?"))<br><null
> alert("Hello World!")<br><null
></pre></font>
</FONT>
<h5>Copyright ©1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>