Solved

making an ifram close itself

Posted on 2003-12-11
4
320 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Check if field exists SPUtility 5 48
Make New Browser Window Fully Functional 7 36
Multiple of Image Swaps 5 41
Angular - why isn't this table working? 20 22
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

739 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