Java Reference
In-Depth Information
return factorialResult;
}
</script>
</head>
<frameset cols=”100%,*“>
<frame name=”fraCalcFactorial” src=”calcfactorial.htm” />
</frameset>
</html>
Save this page as calcfactorialtopframe.htm .
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Example</title>
<script type=”text/javascript”>
function butCalculate_onclick()
{
try
{
if (window.top.calcFactorial == null)
throw “This page is not loaded within the correct frameset”;
if (document.form1.txtNum1.value == “”)
throw “!Please enter a value before you calculate its factorial”;
if (isNaN(document.form1.txtNum1.value))
throw “!Please enter a valid number”;
if (document.form1.txtNum1.value < 0)
throw “!Please enter a positive number”;
document.form1.txtResult.value =
window.parent.calcFactorial(document.form1.txtNum1.value);
}
catch(exception)
{
if (typeof(exception) == “string”)
{
if (exception.charAt(0) == “!”)
{
alert(exception.substr(1));
document.form1.txtNum1.focus();
document.form1.txtNum1.select();
}
else
{
alert(exception);
}
}
else
{
alert(“The following error occurred “ + exception.message);
}
}
}
Search WWH ::




Custom Search