Solved

making an ifram close itself

Posted on 2003-12-11
4
316 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Interview question Javascript, database 12 58
how i fix Remove render-blocking JavaScript 3 53
How to convert from xls to xlsx using java 7 37
Else condition 9 16
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

785 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