468,283 Members | 1,826 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

self.close and parent.location in one link

Hi All,
I have a problem with a simple (as I thought till now) thing:
I want to make a link in a child-window which would change site in the
parent-window and along with closing child window. The parent window
name is "main". A made a link like this in the child-site:

<a href="new_address.html" target="main" class="about"
onclick="javascript:main.location='new_address.htm l';self.close();">
change and close </a>

but it does not work.
I tried also window.close(), window.close(self) and alo put it all in
href instaed of onclick - without success. Although the page in "main"
changes to what I want, but the pop-up is still open.
Strange is that self.close() invoked without anything before it work
normally.

Do you have any idea how can I solve this problem?

Thanks in advance and best regards,
Michal
Sep 18 '08 #1
1 3896
SAM
mi**************@gmail.com a écrit :
Hi All,
I have a problem with a simple (as I thought till now) thing:
I want to make a link in a child-window which would change site in the
parent-window and along with closing child window. The parent window
name is "main".
What about are you talking when you say "parent" window ?
Are you in a framed page ?
(and you really talk of parent's frame or container of the frame)
A made a link like this in the child-site:
and ... what could be a "child-site" ?
<a href="new_address.html" target="main" class="about"
onclick="javascript:main.location='new_address.htm l';self.close();">
change and close </a>

but it does not work.
What is not working ?
You can't close a frame (or iframe), the more you can do is to hide it,
or to suppress it from main page's DOM tree.

If you're talking of framed page (frameset) it is something like :
onclick="parent.main.location = ...
or simply :
onclick="parent.location = ...
and you cant "close" the iframe or frame from its loaded file.
(in any case by 'self.close()' )
I tried also window.close(), window.close(self)
So youren't in a framed page and you're talking about *mother* and
*daughters* windows (popups), no ?

The 'mother' is the "opener" of the 'daughter' and not hers "parent"
In JS a 'parent' is always a 'container' and never an ancestor (previous
and independent object).

<a href="new_address.htm"
onclick="opener.location=this.href; self.close()">Modify</a>

The html target cant reach the 'opener', a target must be an html name
of something displayed in the same window (ie: another frame).

--
sm
Sep 18 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Clive Moore | last post: by
4 posts views Thread by Martin Herrman | last post: by
1 post views Thread by Walter Beierdonck | last post: by
4 posts views Thread by Raymond Wilk | last post: by
1 post views Thread by Steven | last post: by
1 post views Thread by oliver gargour | last post: by
1 post views Thread by liu | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.