Php 如何从iframe中的onclick事件关闭iframe?
我想通过单击iframe中的按钮来关闭iframe,然后返回到父页面 我已搜索,但无法获得适当的代码 有人能帮我吗?试试这个Php 如何从iframe中的onclick事件关闭iframe?,php,javascript,Php,Javascript,我想通过单击iframe中的按钮来关闭iframe,然后返回到父页面 我已搜索,但无法获得适当的代码 有人能帮我吗?试试这个 function closeIframe() [ var iframe = document.getElementById('someid'); iframe.parentNode.removeChild(iframe); } 这里介绍了这一点:使用一种更灵活的跨域功能方法。我在button onclick函数中有类似的功能: parent.location
function closeIframe() [
var iframe = document.getElementById('someid');
iframe.parentNode.removeChild(iframe);
}
这里介绍了这一点:使用一种更灵活的跨域功能方法。我在button onclick函数中有类似的功能:
parent.location.reload();
我想这可能会帮助你:
var theFrame=parent.getElementById("iframeId");
theFrame.parentNode.removeChild(theFrame);
iframe是一个棘手的问题,但我也从中得到了乐趣。尝试从“顶部”文档访问iframe时,您将使用:
top.iFrameToClose = top.document.getElementById("myiFrame");
top.iFrameToClose.offsetParent.removeChild(top.iFrameToClose);
我希望这有助于…您需要为iframe分配一个id,就像
您不能关闭iframe!但是你需要导航到另一个页面。。window.top.location.href=“newlocation.htm”你真的不能把按钮放在外面吗?看看@graphox说的。这将是一个简单的$(“#iframe\u id”).remove()
jQuery调用。
top.iFrameToClose = top.document.getElementById("myiFrame");
top.iFrameToClose.offsetParent.removeChild(top.iFrameToClose);
<a href="javascript: window.parent.document.getElementById('someid').parentNode.removeChild(window.parent.document.getElementById('someid'))">Close</a>