making an ifram close itself

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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Hope i am clear


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
its an iframe. it won't close itself. but you can use CSS to make it vanish.

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

<a href="#" onClick=""iframe1").style.display='none';">Close frame</a>
here's a correct version:

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

<a href="#" onClick="'iframe1').style.display='none'; return false;">Close frame</a>

wjdashwoodAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.