By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,566 Members | 1,723 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,566 IT Pros & Developers. It's quick & easy.

Using window open to change existing window's location

P: n/a
Hi,

I'm trying to change the content of an existing window from a second window
using window.open(). This works fine in Netscape 7, but IE 6.0 returns an
error, saying there's an invalid parameter. If I omit the target window's
name, everything works fine except that my document is opened in a new
window.

window.open("somescript.php", "existing_target_window");

Can anybody see what's wrong with that?

Thanks,
Bernd
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bernd Liebermann wrote:
Hi,

I'm trying to change the content of an existing window from a second
window using window.open(). This works fine in Netscape 7, but IE 6.0
returns an error, saying there's an invalid parameter. If I omit the
target window's name, everything works fine except that my document is
opened in a new window.

window.open("somescript.php", "existing_target_window");

Can anybody see what's wrong with that?

Thanks,
Bernd


Hi,

Do it like this:

var myOtherWin;

if (myOtherWin) {
// already is open
myOtherWin.location="blabla.php";
} else {
// create it
myOtherWin = window.open("somescript.php", "existing_target_window");
}

So the trick is to keep a reference to that window.

Regards,
Erwin Moller

Jul 20 '05 #2

P: n/a
Erwin,

the problem ist that my second window has been opened by the first, so I
don't know how to get a reference to the first that I could use in the
second as there is no global windows collection. Any further ideas?

Thanks,
Bernd Liebermann

"Erwin Moller"
<si******************************************@spam yourself.com> schrieb im
Newsbeitrag news:40*********************@news.xs4all.nl...
Bernd Liebermann wrote:
Hi,

I'm trying to change the content of an existing window from a second
window using window.open(). This works fine in Netscape 7, but IE 6.0
returns an error, saying there's an invalid parameter. If I omit the
target window's name, everything works fine except that my document is
opened in a new window.

window.open("somescript.php", "existing_target_window");

Can anybody see what's wrong with that?

Thanks,
Bernd


Hi,

Do it like this:

var myOtherWin;

if (myOtherWin) {
// already is open
myOtherWin.location="blabla.php";
} else {
// create it
myOtherWin = window.open("somescript.php", "existing_target_window");
}

So the trick is to keep a reference to that window.

Regards,
Erwin Moller

Jul 20 '05 #3

P: n/a
Bernd Liebermann wrote:
Erwin,

the problem ist that my second window has been opened by the first, so I
don't know how to get a reference to the first that I could use in the
second as there is no global windows collection. Any further ideas?

Thanks,


Hi Bernd,

try 'opener'

opener holds a reference to the window that opened the one that is using
opener.

so:
win1 opens win2
from win2 you get a reference to win1 by:

opener.document.location="Doughlas_Adams.html";

There are a few securityrestrictions: if the content in win1 and win2
originate from different domains, some browsers will block cross-window
javascript.

Good luck!

Regards,
Erwin
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.