Solved

making an ifram close itself

Posted on 2003-12-11
4
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…
Suggested Courses

615 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