<html>
<head>
<!-- alert box with line break -->
<script type="text/javascript">
function disp_alert()
{
alert("Hello again! This is how we" + '\n' + "add line breaks to an alert box!")
}
</script>
<!-- prompt box -->
<script type="text/javascript">
function disp_prompt()
{
// this is what is in the prompt box
var name=prompt("Please enter your name","")
// no need to edit next line!
if (name!=null && name!="")
{
// this is what is written when ok is pressed
document.write("Hello " + name + "! How are you today?")
}
}
</script>
<!-- confirm box -->
<script type="text/javascript">
function disp_confirm()
{
// this is what comes up in the box
var name=confirm("Press a button")
if (name==true)
{
// this is what is written if you press Ok
document.write("You pressed the OK button!")
}
else
{
// this is what is written if you press Cancel
document.write("You pressed the Cancel button!")
}
}
</script>
<!-- Alert box -->
<script type="text/javascript">
function click_alert()
{
// change text in brackets to what you want it to be!
alert("This is an alert box")
}
</script>
<!-- This is a alert on load of page -->
<script type="text/javascript">
function message()
{
// change text in brackets to what you want it to be!
alert("Pop-up on load!")
}
</script>
<body onLoad="message()">
<!-- displays alert on click -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="click_alert()"
value="Click Me!">
</form>
<br>
<!-- displays a option box on click -->
<form>
<!-- change yo what you want! -->
<input type="button" onclick="disp_confirm()"
value="Click Me">
</form>
<!-- displays a prompt box -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="disp_prompt()" value="Display a prompt box">
</form>
<!-- displays an alert box with a line break -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="alert()" value="Alert with break">
</form>
</body>
</html>