Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close an iframe within iframe itself

How do I use javascript or jQuery to close an iframe within iframe itself? I've tried <a href="javascript:self.close()"> but it didn't work.

like image 511
Stan Avatar asked Jul 19 '11 22:07

Stan


People also ask

How do I turn off iframe parent window?

window. close(); or this: top. window. close(); you should be able to close it.

Can an iframe show only part of page?

Set the iframe to the appropriate width and height and set the scrolling attribute to "no". If the area you want is not in the top-left portion of the page, you can scroll the content to the appropriate area. Refer to this question: Scrolling an iframe with javascript?


2 Answers

"Closing" the current iFrame is not possible but you can tell the parent to manipulate the dom and make it invisible.

In IFrame:

parent.closeIFrame(); 

In parent:

function closeIFrame(){      $('#youriframeid').remove(); } 
like image 102
citizen conn Avatar answered Sep 28 '22 21:09

citizen conn


function closeWin()   // Tested Code { var someIframe = window.parent.document.getElementById('iframe_callback'); someIframe.parentNode.removeChild(someIframe)); }   <input class="question" name="Close" type="button" value="Close" onClick="closeWin()" tabindex="10" />  
like image 37
user3370889 Avatar answered Sep 28 '22 20:09

user3370889