J
John MacIntyre
Hi,
I have a page with a series of child pages loaded into an iframe. When I
move from page to page, I store an object containing the child's control
data in a variable on the main page, then use that data to populate the
controls when the child page is opened again.
One of these objects contains an Array, and the page reloads fine using
myArray[0], myArray[1], etc... But when I try perform some array methods
on it (i.e.slice) ... it does not recognize it as an array.
By checking "myArray instanceof Array", I have determined that the object
is seen as an array until it is passed to the parent page. Then "myArray
instanceof Array" fails.
Does anybody know why this is? And/Or how I can get around it?
I managed to isolate the problem in the following HTML files.
Thanks in advance,
--
John MacIntyre
VC++ / VB / ASP / Database Developer
http://www.johnmacintyre.ca
-------------------------
--- parent.htm ---
-------------------------
<HTML>
<script>
function getArray()
{
var ca;
ca = ifra.getArray();
alert(ca.join("-"));
alert( "Parent : " + ((ca instanceof Array) ? "Type Array" :
"Unknown
Type"));
}
</script>
<BODY>
<button onclick="getArray()">Check child array type</button><br>
<IFRAME id=ifra name=ifra src="C1.htm"></IFRAME>
</BODY>
</HTML>
-------------------------
--- C1.htm ---
-------------------------
<script>
function getArray()
{
var a = new Array( 1,2,3,5,8,13,21,34,55,89);
return a;
}
function btn_onclick()
{
var a = getArray();
alert( "Child : " + ((a instanceof Array) ? "Type Array" :
"Unknown
Type"));
}
</script>
<BODY>
<button onclick="btn_onclick();">Click for Array</button>
</BODY>
</HTML>
I have a page with a series of child pages loaded into an iframe. When I
move from page to page, I store an object containing the child's control
data in a variable on the main page, then use that data to populate the
controls when the child page is opened again.
One of these objects contains an Array, and the page reloads fine using
myArray[0], myArray[1], etc... But when I try perform some array methods
on it (i.e.slice) ... it does not recognize it as an array.
By checking "myArray instanceof Array", I have determined that the object
is seen as an array until it is passed to the parent page. Then "myArray
instanceof Array" fails.
Does anybody know why this is? And/Or how I can get around it?
I managed to isolate the problem in the following HTML files.
Thanks in advance,
--
John MacIntyre
VC++ / VB / ASP / Database Developer
http://www.johnmacintyre.ca
-------------------------
--- parent.htm ---
-------------------------
<HTML>
<script>
function getArray()
{
var ca;
ca = ifra.getArray();
alert(ca.join("-"));
alert( "Parent : " + ((ca instanceof Array) ? "Type Array" :
"Unknown
Type"));
}
</script>
<BODY>
<button onclick="getArray()">Check child array type</button><br>
<IFRAME id=ifra name=ifra src="C1.htm"></IFRAME>
</BODY>
</HTML>
-------------------------
--- C1.htm ---
-------------------------
<script>
function getArray()
{
var a = new Array( 1,2,3,5,8,13,21,34,55,89);
return a;
}
function btn_onclick()
{
var a = getArray();
alert( "Child : " + ((a instanceof Array) ? "Type Array" :
"Unknown
Type"));
}
</script>
<BODY>
<button onclick="btn_onclick();">Click for Array</button>
</BODY>
</HTML>