Corrections made:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Two Functions</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */
function printMessage(first_message)
{
document.write("<p>" + first_message + "</p>");
}
function return_message()
{
return "<p>This message was returned from a function.</p>";
}
/* ]]> */
</script>
</head>
<body>
<script type="text/javascript">
/* <![CDATA[ */
printMessage("This message was printed by a function.");
var return_value = return_message();
document.write(return_value);
/*]]> */
</script>
</body>
</html>
Note that in your post you had these lines:
Code:
return "<p>This message was returned from
a function.</p>");
printMessage("This message was printed
by a function.");
I can't tell if that's an artifact of how you posted or if your code is really like that.
If it's really like the, you need to know that a JavaScript string literal (text between quote marks) can *NOT* be broken across more than one line.
If the text is long, you must break it into two literal strings and concatenate them.
Example:
Code:
printMessage("This message was printed"
+ " by a function.");