469,643 Members | 1,918 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Window.open and window.setFocus

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
1 27317
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.

Similar topics

5 posts views Thread by Yang Li Ke | last post: by
2 posts views Thread by Len4ik | last post: by
9 posts views Thread by Mark | last post: by
6 posts views Thread by Jack | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.