943,809 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Mar 20th, 2008
0

Re: Parent/Child Windows References

Click to Expand / Collapse  Quote originally posted by mleneveut ...
Hi,

I have the same problem, and I can't achieve to serialize my popup reference.

I tried with JSON and a lot of different libraries :

var popupVar = window.open('url', 'name');
var serializedString = JSON.encode(popupVar);
var serializedString = popupVar.toJSONString();
...

Every time I have errors. I could catch it with IE, and it says : [Object error]. Great :p
In Firefox it just crashs it...

I did'nt find any real example on serializing JS "native" objects, only JS "created" objects (like var Person = { this.id; this.name; })

Does someone achieve it ? Know how to serialize this popupVar ?

Thanks a lot
Hi,
I have the exact same java script issue where even if my parent window reloads, it should still be able to hold the child window references. Did you manage to get a solution for that. Any help would be appreciated.
Thanks in Advance.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sprash is offline Offline
1 posts
since Mar 2008
Mar 22nd, 2008
0

Re: Parent/Child Windows References

> even if my parent window reloads, it should still be able to hold the child window
> references.

AFAIK, you simply can't. To put it in simple terms, the Javascript variables disappear after a page reload. After all Javascript is a client side technology.

A work around would be to store all the information you need to maintain inside a cookie i.e. whether the child window was open or not and if yes then what were it's contents; at the same time being aware of the 4KB limit imposed on the cookie size.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Mar 22nd, 2008
0

Re: Parent/Child Windows References

Click to Expand / Collapse  Quote originally posted by ~s.o.s~ ...
> even if my parent window reloads, it should still be able to hold the child window
> references.

AFAIK, you simply can't. To put it in simple terms, the Javascript variables disappear after a page reload. After all Javascript is a client side technology.

A work around would be to store all the information you need to maintain inside a cookie i.e. whether the child window was open or not and if yes then what were it's contents; at the same time being aware of the 4KB limit imposed on the cookie size.
You can't store a popup window reference in a cookie as it is directly dependent on the current parent window/document which is a javascript host object.
However, if you could persist the current window to the next reload in the browser, you could also persist reference to open windows, and other objects (dependents).

Unfortunately I cannot release the code for this right now, as I would like to, as we have a patent pending. I will try and get this code out in ASAP as I know this is needed in many areas of web development, especially the web2.0.

As soon as we get the patent sorted you will be able to persist references to host objects in javascript between the loading of new windows.

At the moment I am interested in any other methods that may have been discovered to do this, though I have not found any so far.

-- update:

I'll add some code to demonstrate persistence of javascript native and host objects after I get it tested in a majority of browsers and OS's.
Last edited by digital-ether; Mar 22nd, 2008 at 12:19 pm.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Mar 22nd, 2008
0

Re: Parent/Child Windows References

You can't store a popup window reference in a cookie as it is directly dependent on the current parent window/document which is a javascript host object.
However, if you could persist the current window to the next reload in the browser, you could also persist reference to open windows, and other objects (dependents).
Read my post carefully; I talk of persisting the child window 'information' and not the child window itself which seems to make little sense.

You could store information like the child windows' attributes like its height, width, position etc. in a cookie. On a document load, your javascript function would then check the contents of the cookies and then re-create a child window based on the flag 'recreateNeeded' which would be either true or false or 0 or 1 (the way you want it to be). Of course this means persisting the child window information at regular intervals and writing a custom mini parser which would parse the contents of the cookie at load time but yes, it's very much possible with a bit of effort .
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Sep 3rd, 2010
0
Re: Parent/Child Windows References
The simplest way I found is to use the fact that when your child window is named and you try to open a new pop up with the same name it automatically refers to already opened window. Here's the way to do it.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. window.open('test.html','WindowName','',''....);// open the child window for first time
  2. WindowRef = window.open('','WindowName','',''....);// it assigns the reference for the same child window to the variable
  3. Note that url parameter is left blank and Pop up window name is the same. It refers to the same child window and assigns the reference object to variable "WindowRef".
The best part of the above code is that you can take the reference of the window regardless of the parent page refreshing.'
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. Now when you need to refer the child window simply do it by
  2. WindowRef.close(); // close the child window
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amitnishad is offline Offline
1 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Radio Button onClick Javascript calling only once
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: coldfusion dynamic table and Ajax





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC