471,092 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

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.location=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]
Jul 23 '05 #1
2 1240
Ivo
"Sandman"wrote
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.location=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?

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='mainwindow';

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

var el=parent.opener;
while( el.opener && el.name !== 'mainwindow'' ) el=el.opener;
el.location=what;

HTH
Ivo
Jul 23 '05 #2
Sandman wrote:
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.location=what;
}
Why "parent" ?
Mick
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?

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mannerfanner | last post: by
7 posts views Thread by Alan Little | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.