RESPOND WITH DOCUMENT.WRITE
You can also choose to respond by writing something to the page, either as an alternative to an alert, or in addition to an alert, as in the following code:
var fname = prompt
("Please enter your first name: ",'');
alert ("Hello, " + fname);
document.write ("Hello, " + fname);
Create a page to include this code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Prompt and Alert</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="JavaScript">
<!--
var fname = prompt
("Please enter your first name: ", "");
alert ("Hello, " + fname);
document.write ("Hello, " + fname);
// -->
</script>
</head>
<body>
</body>
</html>
Notice that there's nothing in between the body tags, so nothing displays on
the page until the document.write statement is read by the
browser.
