[CLOSED] Closing a parent window from a child iFrame button (dynamic window ID's)

  1. #1

    [CLOSED] Closing a parent window from a child iFrame button (dynamic window ID's)

    Hi All,

    I've got an situation where we'd like to close a parent window from a button within a nested child iFrame.

    I've had a read around and most of the solutions seem to centre around using 'window.parent' and a reference to the WindowID. This works ok if you know the ID of the window, but with the app we're currently working it, we're using the desktop control, and window ID's are created dynamically.

    This leaves us with a situation where if I Page.aspx it's ID might be 'win_1' whereas if I then open the same page again it might be 'win_2'.

    Has anyone stumbled accross an effective mechanism to determine the parent windows ID from the child iFrame's button?

    At the moment I've spent some time trying to use a recursive method to traverse the DOM up to the parent window (which seems to bail when I hit the top of the iFrame).
    Also tried a few ways to pass the current window's ID about, perhaps in the querystring when opening it and then parsing that back out with window.document.location.search, that kind of thing.

    I'm sure someone must have encountered this before, any pointers would be greatly appreciated.

    Many thanks,

    Last edited by Daniil; Feb 09, 2012 at 10:05 AM. Reason: [CLOSED]
  2. #2

    Please ask any technical support questions on the Premium Help forums since you are a premium member. We can miss your question on another forums.

    Regarding the question.

    Please use "parentAutoLoadControl" within a frame.
  3. #3
    Hi Daniil,

    I will in the future certainly, only got my account switched over yesterday hence I was a normal member when I posted :)

    Thanks for the solution, works perfectly, can't believe I never noticed that method before!
  4. #4
    Ok, then welcome to the Premium Help :)
  5. #5
    Just in case it helps others, if (as in my case) you have a window which contains and iFrame (tab panel in my example) and then that window contains further iFrames (the tabs) to close the overall window, you can just append window.parent to the call to ensure that you don't just close the tab and do close the overall containing window.
  6. #6
    One final question on this topic Daniil, would it be considered best practice to use the
    function over a static reference to say 'windowMyWindow.hide()'?

    I'm guessing that the lack requirement for a window reference could be generally useful if another developer changes your window name, but are there any performance implications of not calling the method directly on the window component?
  7. #7
    There is no difference in performance.

    A "parentAutoLoadControl" is just a reference to access the same Window as its client id reference.

    It looks something like this:
    var windowClientId = new Ext.Window(),
        parentAutoLoadControl = windowClientId;
    No difference you will call:
  8. #8
    Perfect, thanks for the clarification Daniil

Similar Threads

  1. [CLOSED] Problem: Closing Maximized Window will loose parent window scrollbar
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 19, 2012, 8:51 PM
  2. Replies: 6
    Last Post: Feb 15, 2012, 4:15 PM
  3. [CLOSED] How to display child window outside Parent window
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2010, 11:06 AM
  4. Replies: 0
    Last Post: Jul 28, 2009, 3:53 PM
  5. Replies: 1
    Last Post: Apr 01, 2009, 12:24 PM

Tags for this Thread

Posting Permissions