473,434 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Losing reference to constructor when passing an array between windows.

If I have a parent and a child window, and if I create an array in the
child window, and pass it as a parameter to the parent window, it's
still an array, and its methods still work (like the 'forEach').

However, if I try to figure out if it's an array by looking at the
constructor property, I get that it's not an array. I got this behavior
in IE6 and Firefox, is this a bug or am I doing something wrong? I
pasted the code below.
Thanks!
Carlos

parent.html
================================================== ====
<html><body><script type="text/javascript">
var childWindow = window.open("child.html", "childWindow");
function functionInParentWindow(anArray){
if (anArray.constructor == Array){
alert("expected behavior");
} else {
alert("bug?");
}
}
</script></body></html>
================================================== ====

child.html
================================================== ====
<html><body><script type="text/javascript">
var parentWindow = window.opener;
var anArray = [];
anArray.push('0');
parentWindow.functionInParentWindow(anArray);
</script></body></html>
================================================== ====

Oct 4 '06 #1
1 1850
I found my answer at:

http://groups.google.com/group/comp....fbcb0da1cd4aef
Carlos Aguayo wrote:
If I have a parent and a child window, and if I create an array in the
child window, and pass it as a parameter to the parent window, it's
still an array, and its methods still work (like the 'forEach').

However, if I try to figure out if it's an array by looking at the
constructor property, I get that it's not an array. I got this behavior
in IE6 and Firefox, is this a bug or am I doing something wrong? I
pasted the code below.
Thanks!
Carlos

parent.html
================================================== ====
<html><body><script type="text/javascript">
var childWindow = window.open("child.html", "childWindow");
function functionInParentWindow(anArray){
if (anArray.constructor == Array){
alert("expected behavior");
} else {
alert("bug?");
}
}
</script></body></html>
================================================== ====

child.html
================================================== ====
<html><body><script type="text/javascript">
var parentWindow = window.opener;
var anArray = [];
anArray.push('0');
parentWindow.functionInParentWindow(anArray);
</script></body></html>
================================================== ====
Oct 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
86
by: Michael Adams | last post by:
I don't know if you have noticed, but it seems like Microsoft is losing interest in C#, and putting their energy into Visual Basic.NET instead. For instance, online chats by language since July...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
8
by: toton | last post by:
HI, One more small doubt from today's mail. I have certain function which returns a pointer (sometimes a const pointer from a const member function). And certain member function needs reference...
9
by: Jack | last post by:
If I don't specify "ref" in the argument list when passing an array to the callee, I am passing the array (reference) by value. But this makes me confused because it actually means a "reference" of...
4
by: Vince13 via DotNetMonster.com | last post by:
I am trying to set up a page where the user can change data, and then click cancel and the data will not be saved. Currently, I am saving the data in a Session variable that is an array of a class...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.