Today i was trying to study about frameset by creating a few pages , this is how the site works , the frameset-defining page is divided into two separate child frame , and inside the two pages contain a textarea and a button that will print out the pages that are visited to the textarea when user click the button,the page is as follow:
The frameset-defining page<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Example</title>
<head>
<script type="text/javascript">
var siteList = new Array();
function returnPageVisited_onclick()
{
var returnValue = "The pages you've visited : " + "\n"
for(var i = 0 ; i < siteList.length ; i++)
{
returnValue += siteList[i] + "\n";
}
window.document.myForm.pageVisited.value = returnValue;
}
function printSiteLs_onload(fileNameStart)
{
var pageName = fileNameStart.lastIndexOf("/") + 1;
siteList[siteList.length] = fileNameStart.substr(pageName);
}
</script>
</head>
<frameset cols="50% , *">
<frame src="pageA.html" name="fraLeft" />
<frame src="pageB.html" name="fraRight" />
</frameset>
</html>
the frame page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Example</title>
<head>
</head>
<body onload="window.parent.printSiteLs_onload(window.location.href);">
<h2> This is Page A </h2>
<p>
<a href="pageA.html">Page A</a>
<a href="pageB.html">Page B</a>
<a href="pageC.html">Page C</a>
<a href="pageD.html">Page D</a>
</p>
<form name="myForm">
<textarea name="pageVisited" rows="10" cols="35">
</textarea>
<input type="button" name="myBtn" value="Click To Check" onclick="window.parent.returnPageVisited_onclick()"/>
<br />
</form>
</body>
</head>
</html>
There are another 3 pages which are coded the same as the frame page above,just the line <p> This is page A</p> is different , my problem is the line of code in the frameset-defining page ,that is window.document.myForm.pageVisited.value = returnValue; for the first function , firebug gave me an error "window.document.myForm is undefined",here is how I think,I'm using the frameset to create a module to store generic function so that other pages could access the function in it,but I wonder why I'm getting this error since the function is not called in the mainpage but is called in the frame pages where myForm is defined,so why am I still getting this kind of error,much appreciated if someone could correct my statement if I'm wrong thank you