如何使用javascript或jQuery在iframe中关闭iframe?我尝试过<a href="javascript:self.close()">,但它不起作用。
发布于 2011-07-20 06:38:24
“关闭”当前的iFrame是不可能的,但您可以告诉父dom操作dom并使其不可见。
在IFrame中:
parent.closeIFrame();在parent中:
function closeIFrame(){
$('#youriframeid').remove();
}发布于 2014-03-02 22:25:22
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" /> 发布于 2015-02-23 17:58:08
使用此选项可从iframe本身的父级中删除iframe
frameElement.parentNode.removeChild(frameElement)仅适用于同一来源(不允许跨来源)
https://stackoverflow.com/questions/6754935
复制相似问题