/    Sign up×
Community /Pin to ProfileBookmark

Passing a window as a parameter

Hello,

My WEB site opens an application window and then, from its original window it navigates to a status page.
Code:

[CODE]var newWindow
function popUpApplication() {
newWindow = window.open(url, parameters…);
window.location.href = statuspage.jsp;
}[/CODE]

Now I would like to have access to the application window handle from statusPage.jsp, is it possible and if yes then, how is it done?

On a separate thread that I marked as resolved a bit to early WolfShade suggested:

[QUOTE]

Untested:
Code:

[CODE]var newWindow
function popUpApplication() {
newWindow = window.open(url, parameters…);
window.location.href = “statuspage.jsp?window=newWindow”;
}[/CODE]

Then in statuspage.jsp..
Code:

[CODE]var windowHandler;
thisURL = document.URL;
thisURLarray = thisURL.split(“?”);
thisQS = thisURLarray[1];// Everything after the ‘?’
thisParam = thisQS.split(“=”);
windowHandler = thisParam[1];[/CODE]

.. and then whatever you do would have to be in an eval(), unless someone can figure out a better way to execute.

[/QUOTE]

The problem of this solution is that the parameter received from the URL is the string “[object]” that can not be evaluated to anything usefull.

Another idea by “rnd me” was that:

[QUOTE]

if you call window.open twice on different pages upon the same site, passing identical an identical ID as argument2 each time, you can re-use the popup.

the other way is to set window.name to the name of the popup.
window.name survives refreshes/page changes, so it’s like url params but without the splitting headache.

[/QUOTE]

Now the problem with this solution is that if the window was closed by the user I will end up with a new pop up window, which I would like to avoid… Unless there is a way to check for window existence prior to attempting to create a new window.

Any other suggestion, code fix for the previous ones?

Thanks all

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meMay 13.2011 — use JSON.stringify and JSON.parse to store/fetch objects in window.name or the "querystring"...

or use cookies, they don't warp the url and are very simple way to talk between pages on the same site.
×

Success!

Help @brouleau21 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...