Solved

making an ifram close itself

Posted on 2003-12-11
4
314 Views
Last Modified: 2008-03-10
I'm sure this should be really simple but for some reason I can't get it to work.
I have a text link and I want it to close the iframe it is in.
I have <a href="javascript:onClick=self.close()">Close</a>
but it doesn't work. Can anyone tell me why and tell me a way which will work?

Thanks,
H
0
Comment
Question by:wjdashwood
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
p_partha earned 100 total points
ID: 9920866
As far as my knowledge goes,iframe is a part of the page, u cannot close the iframe, although u can hide the iframe

give a iframe an id like this..

<iframe id='test' blah blah..


and when u want to hide it, just say
document.getElementById("test").style.display='none'

Hope i am clear

Partha
0
 
LVL 7

Assisted Solution

by:gam3r_3xtr3m3
gam3r_3xtr3m3 earned 200 total points
ID: 9920940
its an iframe. it won't close itself. but you can use CSS to make it vanish.

main
------
<iframe src="iframe.html" id="iframe1"></iframe>

iframe.html
-------------
<a href="#" onClick="window.top.document.getElementById("iframe1").style.display='none';">Close frame</a>
0
 
LVL 7

Assisted Solution

by:gam3r_3xtr3m3
gam3r_3xtr3m3 earned 200 total points
ID: 9920974
error:
here's a correct version:

main
------
<iframe src="iframe.html" id="iframe1"></iframe>

iframe.html
-------------
<a href="#" onClick="window.top.document.getElementById('iframe1').style.display='none'; return false;">Close frame</a>

0
 

Author Comment

by:wjdashwood
ID: 9921242
well, you are all right, thats how i did it in the other, just me being stupid! I needed to hide it, not close it.

Thank you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now