/    Sign up×
Community /Pin to ProfileBookmark

Child window showing

Hi there,

In one of my projects we are popping up a order form (using window.open) and then we store the resulting window object in a variable (formWindow). Then when a user clicks the link again we do not reload the order form but instead give focus to the order form.

This way the user can be browsing the product catalog and then click order to focus on the order form and add other product ids to their order.

The problem is that when the user changes his location in the product catalog then we obviously loose the formWindow variable and thus the ability to showing the form instead of reloading it when a user clicks the order link. Is there any way to reget the window object we once opened?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisFeb 28.2003 — If your formWindow has a name, you can reestablish a link by using window.open().

[font=monospace]formWindow = window.open("","formWindow");[/font]

If formWindow is already open, then you just get a pointer. If it's not, an empty window called formWindow will be opened.
Copy linkTweet thisAlerts:
@IceSageauthorFeb 28.2003 — Thats what I tried at first but that just reloaded the order form in the child window (I did not want it reloaded, just to put focus on the child window)

However I've found a solution to the problem I was having. I put a setInterveral("connectToParentWindow()", 1000); in the child window and that function was something like this:

if (window.opener)

{

window.opener.formWindow = window;

}

This recreates the link by assigning the variable in the parent window. This solution workes perfectly and works on all browsers and platforms.

But thanks for the help anyway.
×

Success!

Help @IceSage 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.19,
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,
)...