Window.open and window.setFocus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Smeets

    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
  • Thomas 'PointedEars' Lahn

    #2
    Re: Window.open and window.setFocus

    Ben Smeets wrote:
    [color=blue]
    > 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?[/color]

    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.)
    [color=blue]
    > Is there a way to call a child by using it's window name,[/color]

    Use Google (Groups). `NAME' is _not_ the window's (internal) name,
    it is the identifier of a reference to the created Window object.
    [color=blue]
    > the one you give it when using window.open?[/color]

    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

    Comment

    Working...