Forum Moderators: open

Message Too Old, No Replies

Open"target" window while closing open window

         

joshenry

5:36 pm on May 27, 2005 (gmt 0)

10+ Year Member



Hi,

When opening a new "target" window, it opens a new window while leaving the old window still open. If the new "target" window exists, it simply re-opens that window, not a new one ...that's what I want to do, but I want to close the old window.

the scenario: MainPage has a link that opens a new window named "New1". Window New1 has a link that opens a new window named "New 2". Now I want a link on page New 2 to open a new page in window "New1" (which is already open) while at the same time closing itself (window "New2").

Is there any way to do this [in the "HREF" tag] ...or any way at all?

Joseph

PS: the admin in html/browser forum offered this approach:

<a href="#" onClick="window.opener.parent.location='newpage.html';window.close();">

but I couldn't get that to work. He suggested I try this forum.

Joseph

RonPK

8:14 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> <a href="#" onClick="window.opener.parent.location='newpage.html';window.close();">

Try this:

<a href="#" onClick="window.opener.location='newpage.html';window.close();">

joshenry

8:44 pm on May 27, 2005 (gmt 0)

10+ Year Member



Sorry, still no go

RonPK

9:07 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any error messages?

kaled

9:50 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try location.href=

also, onclick should return true.

Kaled.

joshenry

10:45 pm on May 27, 2005 (gmt 0)

10+ Year Member



I tried all the combinations I could think of.

<a href="#" onClick="window.opener.parent.location='newpage.html';window.close();">

<a href="#" onClick="window.opener.location='newpage.html';window.close();">

<a href="#" onClick="window.opener.parent.location.href='newpage.html';window.close();">

<a href="#" onClick="window.opener.parent.location='newpage.html';window.close(); return false;">

<a href="#" onClick="window.opener.parent.location='newpage.html';window.close(); return true;">

I get nothing ...no error messages, nothing. Nothing at all happens

RonPK

9:21 am on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless you're using a frameset in window new1, there is no need for '.parent'.

What browser are you using? Mozilla, Firefox and Opera have excellent built-in Javascript consoles, which show nice, readable error messages.

Rambo Tribble

1:39 pm on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mozilla will only allow a script to close a window which the script has opened, which is a security feature. IE gives a warning if a script attempts to close the main browser window.

If the user has set permissions appropriately in Moz's Preferences, a script can resize and/or move the main window, but not close it.

Dijkgraaf

1:21 am on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can overide the error in IE however by setting the window.opener property.

<a href="#" onClick="window.open('newpage.html');window.opener='anything';window.close();">click here</a>

joshenry

6:23 am on Jun 1, 2005 (gmt 0)

10+ Year Member



Thanks for all the input, guys