473,734 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><sc ript type="text/javascript">
var childWindow = window.open("ch ild.html", "childWindo w");
function functionInParen tWindow(anArray ){
if (anArray.constr uctor == Array){
alert("expected behavior");
} else {
alert("bug?");
}
}
</script></body></html>
=============== =============== =============== =========

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

Oct 4 '06 #1
1 1865
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><sc ript type="text/javascript">
var childWindow = window.open("ch ild.html", "childWindo w");
function functionInParen tWindow(anArray ){
if (anArray.constr uctor == Array){
alert("expected behavior");
} else {
alert("bug?");
}
}
</script></body></html>
=============== =============== =============== =========

child.html
=============== =============== =============== =========
<html><body><sc ript type="text/javascript">
var parentWindow = window.opener;
var anArray = [];
anArray.push('0 ');
parentWindow.fu nctionInParentW indow(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
5448
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 machine then it works again. here is one of the method where am calling the AD public bool UserExist(string UserName) {
86
3629
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 1, 2004: VB.NET 47 C# 6 C++ 8 J# 0
6
5581
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 object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
3
2105
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 when I pass a class as a parameter to a Windows Form. Basically, I have a class that has several fields, two of these fields are an instance of an inner class, the rest are basic value types (bool's in this case). I have a windows form, the...
8
2400
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 (or better a const reference). for eg, const PointRange* points = cc.points(ptAligned);
9
2445
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 a "reference"??As I pass the array by value, the callee can change that array. However,when I use ref, the callee and caller point to two different arrays. So could anyone please explain the 2 different situations?
4
2333
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 I created: public class cut { public cut() { ParallelDim = 'G'; cutPoint = ++numCuts;
275
12337
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
10300
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 may also open up new chat windows with other members (just not the same one). - Each chat page is opened with the member name as the window name. - When I log off from the web page, I would like all the chat windows to automatically close. I...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.