By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Window.open and window.setFocus

P: n/a
Hi folks,

Have been trying to figure out a solution for the following problem by
reading lots of threads here, but doesn't work out. Hope someone can
help me.

I have a parent window which opens a popup window (child). What i
would like to do, is to be abke to keep surfing to other pages in the
parent and after (lets say) a couple of new pages, still be able to
say "child.setFocus()";

The solutions i found here for setting focus on childs, all have to do
with:

var NAME = window.open......
NAME.setFocus....

But after refreshing the parent, i won't have the ability to call NAME
anymore or do i? Is there a way to call a child by using it's window
name, the one you give it when using window.open?

tnx in advance, Ben
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ben Smeets wrote:
I have a parent window which opens a popup window (child). What i
would like to do, is to be abke to keep surfing to other pages in the
parent and after (lets say) a couple of new pages, still be able to
say "child.setFocus()";

The solutions i found here for setting focus on childs, all have to do
with:

var NAME = window.open......
NAME.setFocus....

But after refreshing the parent, i won't have the ability to call NAME
anymore or do i?
No, you have not, `NAME' is then forgotten. The same goes for access after
navigating to other pages. You can workaround that, e.g., when using a
frameset and store the reference as property of the frameset Window object:

parent.NAME = window.open(...);

(Although JavaScript is case-sensitive, `NAME' as property for Window
objects is to be avoided since such objects already have a `name' property.)
Is there a way to call a child by using it's window name,
Use Google (Groups). `NAME' is _not_ the window's (internal) name,
it is the identifier of a reference to the created Window object.
the one you give it when using window.open?


If the window referenced by `NAME' is still open,

(window.open("...", "foobar", "...") || window).focus();

will do the trick. `foobar' is the same name you used when openened
the window the first time. However, the `foobar' window will most
certainly refresh before it is focused even if the URL is the same.
PointedEars
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.