Solved

How do I close an IFRAME insde the IFRAME?

Posted on 2009-05-07
6
212 Views
Last Modified: 2012-05-06
How do I close an IFRAME insde the IFRAME?

I want the user to click OK inside the IFRAME to close the IFRAME.

How do I accomplish this?
0
Comment
Question by:pmsguy
[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
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Ronb23
ID: 24329898
Inside the iFrame, add a JavaScript function
<script>
function closeIframe() {
   var iframe = document.getElementById('someid');
   iframe.parentNode.removeChild(iframe);
}
</script>

And then add a button or link to close that iFrame:
<a href="javascript: closeIframe()">Close</a>

hope this helps.
0
 

Author Comment

by:pmsguy
ID: 24329978
OK, The problem is the calling program is NOT on the same domain as the IFRAME.

From my PC is call a program on www.someserver.com

I get an error "Permission denied to get property..." when I try to close the IFRAME from my program on my PC.
0
 
LVL 4

Expert Comment

by:Ronb23
ID: 24330394
Let me have a better understand of your setup:
- There is server1 that's hosting www.server1.com
- There is server2 that's hosting www.server2.com
- Server2 have an iFrame that's calling to display www.server1.com
- On your PC, you have a program or a local webpage? that's calling www.server2.com in an iFrame

Let me know if I have this right. If not, please explain the setup and we'll go from there.

Thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pmsguy
ID: 24330863
Yes that is correct
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 24331873
pmsguy,

It won't work.  The browser prevents it.  It is called cross site or cross domain scripting.  Javascript can't change content on another domain, server or different protocol.  If your code is on your domain and the iframe is in code on another domain then you can't do it.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24337427
Thanks for the fun question, the grade and the points.
bol
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

690 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