Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use close window button in Iframe to close parent window

Status
Not open for further replies.

ASH360

Technical User
Sep 3, 2010
1
GB
Hi,
I would like to use a close window button in an iframe with the effect of closing down the window. I've had a good look - a novice I'm afraid - but I do undersand that a fucntion call has to be made to the parent window. I have access to the html in both Iframe and parent and would be grateful if someone could help me with this.
Showing the code in full would be a godsend.
Many thanks
Kind Regards
Mark
 
While the access would be somewhat straight forward:
Code:
<input type=button value="Attempt to Close" onClick="parent.window.close(); return false">

There is no guarantee it will actually work for several reasons.

If the iframe's content comes from a domain different to the parent window it has no access to the parent window so no access to the window's methods like close().

<iframe src="
Also browsers have settings to disable the closing of windows by scripts that did not open them.

In other words closing a window from a script in an iframe is not likely to work for the most part.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top