Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get a window reference?

    I have a window with links, some of these links open another window. If that window is already open, it opens that link in the same window.

    The problem is, I don't want to reload this new window every time, I just would like to call a function inside it, if it is already open. To do so I need a reference to it. How can I get the reference to this window?

    The opener window can be reloaded, so I can't just store it in a variable.

    Hope it makes some sence...
    /Daniel

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are using JavaScript to open the new window like this:
    NewWin=window.open(..)

    Then you can reference the window using the variable NewWin. So to reference a function in that window you could try NewWin.function_name().

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for answering, but I meant it slightly different...



    The problem is when the opener window has been reloaded, and I'd like to call a function in the new window.

    Image this scenario:

    1. Load main window.

    2. Click on link that opens a new window (child window).

    3. Click on the same link in the main window. This time the child window is already loaded, so I just want to call a function.

    4. Click on a link in the main window, that reloads itself.

    5. Click on that first link in the main window again. The child window is still loaded, so I only want to call a function again.

    How can I get the reference to the child window this time?
    /Daniel

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basically you want to get access to all the desktop windows - whether the main window created it or not.

    I posted this question a while back. The reply was - cannot do it in JavaScript.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, that figures...

    I thought there might be a way since there is a frames-collection, which is supposed to hold all window-objects created by the current document. The problem is how to reach it...

    If I create the window like this:
    Code:
    var newWin=open("url.html","newWinName","");
    ..shouldn't it be possible to access a function in the new window using something like:
    Code:
    window.frames("newWinName").functionInNewWindow();
    The name parameter seems to be different than the frame.name property, though...
    /Daniel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •