backt next

Pop Up Box


  Alert
This command pops up a message box displaying whatever you put in it.

<body>
<script language="JavaScript">
<!--

alert("Type your message here.");
//-->
</script>
</body>



Click Here for output

To understand what is going on, take a look at how the link is coded.

<a href="JavaScript: alert('Type Your Message Here')">Click Here</a>




<form>
<input type="button" value="Click Here" onClick="alert('Type Your Message Here.')">
</form>


  Prompt
Prompt is used to allow a user to enter something, and do something with that info.

<body>
<script language="JavaScript">
<!--

var x=prompt("Please Enter Your Name.");
alert("hello "+ x)
//-->
</script>
</body>




<form>
<input type="button" value="Click Here" onClick="var x=prompt('Please Enter Your Name.'); alert('hello '+ x)">
</form>



Back to JavaScript homepage | Back | Next | Email me