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

self.close and parent.location in one link

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.