【问题标题】:remove an iframe from parent from within the iframe itself从 iframe 本身中从父级移除 iframe
【发布时间】:2012-05-18 20:04:48
【问题描述】:

我在域 A 中有一个 iframe

<iframe id="iframeid" src="domain-B/abc.php"  scrolling="no" allowTransparency="true" frameborder="0" style="top: 0%; width:100%;height:100%;left:0;overflow:auto;position: fixed;z-index: 100000;text-align:center;line-height:normal;_position: absolute;"></iframe>

一旦单击该交叉按钮,abc.php 就有一个带有交叉按钮的 div,我使用 jquery 来隐藏该 div。 div 被移除,但父页面不可点击(因为 iframe)

我想在单击交叉按钮后立即删除整个 iframe,以便再次单击父页面。我知道这是一个跨域问题,并且我看到了一些类似的问题,但我无法找到解决方案.

【问题讨论】:

标签: javascript jquery css iframe cross-domain


【解决方案1】:

将此添加到父级:

function childClose() {
    $('#iframeid').remove();
}

然后在 iFrame 中调用它:

document.domain = 'domain.com';
$('selector').click(function(){parent.childClose();});

但是,如果域不同,这将不起作用。

【讨论】:

  • 这不起作用,因为父页面与 iframe 的域不同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-09
  • 1970-01-01
  • 2018-05-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多