parent.opener in several levels.

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

    #1

    parent.opener in several levels.

    I have a site that make use of popup windows (on demand, i.e. when one clicks
    on a link) to open up comments to texts in and such. It works great, but I have
    a problem.

    I have a small javascript that I use when I want to open a link in the "main"
    window which looks like this:

    function quicklink(what) {
    parent.opener.l ocation=what;
    }

    This one works great, but sometimes, my popup window opens a popup window (may
    sound weird to do, but there are occasions where it's quite logical) and using
    quicklink() in this third window will open the link the the second, popup
    window when I really would want to open it in the first, main window.

    Is there are way to handle this, regardless of number of levels of opened
    windows?

    --
    Sandman[.net]
  • Ivo

    #2
    Re: parent.opener in several levels.

    "Sandman"wr ote[color=blue]
    > I have a site that make use of popup windows (on demand, i.e. when one[/color]
    clicks[color=blue]
    > on a link) to open up comments to texts in and such. It works great, but I[/color]
    have[color=blue]
    > a problem.
    >
    > I have a small javascript that I use when I want to open a link in the[/color]
    "main"[color=blue]
    > window which looks like this:
    >
    > function quicklink(what) {
    > parent.opener.l ocation=what;
    > }
    >
    > This one works great, but sometimes, my popup window opens a popup window[/color]
    (may[color=blue]
    > sound weird to do, but there are occasions where it's quite logical) and[/color]
    using[color=blue]
    > quicklink() in this third window will open the link the the second, popup
    > window when I really would want to open it in the first, main window.
    >
    > Is there are way to handle this, regardless of number of levels of opened
    > windows?
    >[/color]
    You 're npot making it very easy on yourself or your users, I guess you
    realize that already. What you can do is name the original window, like so:

    window.name='ma inwindow';

    then have the function check the chain of openers for that name, like so:

    var el=parent.opene r;
    while( el.opener && el.name !== 'mainwindow'' ) el=el.opener;
    el.location=wha t;

    HTH
    Ivo


    Comment

    • Mick White

      #3
      Re: parent.opener in several levels.

      Sandman wrote:
      [color=blue]
      > I have a site that make use of popup windows (on demand, i.e. when one clicks
      > on a link) to open up comments to texts in and such. It works great, but I have
      > a problem.
      >
      > I have a small javascript that I use when I want to open a link in the "main"
      > window which looks like this:
      >
      > function quicklink(what) {
      > parent.opener.l ocation=what;
      > }[/color]

      Why "parent" ?
      Mick[color=blue]
      >
      > This one works great, but sometimes, my popup window opens a popup window (may
      > sound weird to do, but there are occasions where it's quite logical) and using
      > quicklink() in this third window will open the link the the second, popup
      > window when I really would want to open it in the first, main window.
      >
      > Is there are way to handle this, regardless of number of levels of opened
      > windows?
      >[/color]

      Comment

      Working...