【问题标题】:How to close a popup and redirect to an iframe?如何关闭弹出窗口并重定向到 iframe?
【发布时间】:2013-06-11 17:11:27
【问题描述】:

我有一个包含 iframe 的页面,该 iframe 会打开一个弹出窗口。

提交表单后,此弹出窗口应关闭并重新加载打开它的 iframe。

弹窗关闭并通过这种方式重定向:

window.opener.location.href = "http://www.myweb.com/iframe.php";
window.close ();

当我直接从 iframe 工作时,这对我有用,但是当我从包含 iframe 的页面执行此操作时,iframe 不会刷新。

那么...在这种情况下如何重新加载 iframe?

【问题讨论】:

  • 更改其src 属性怎么样? (如果更改为相同的内容不起作用,请尝试在末尾添加 ?foo=bar 或另一个缓存中断器。
  • 您可以从父级更改 iframe 的 url 吗? [又名正文中包含 iframe 的页面?]
  • 尝试parent.window.close();或调用父parent.closec_click()中的函数,并在父页面中定义close_click函数。
  • iframe 是否与页面来自同一来源?也就是说,它们是否来自同一个域?
  • 好吧,如果 iframe 的 DOM 与包含页面的来源不同,则无法访问它。

标签: javascript redirect iframe popup window.opener


【解决方案1】:

好吧,如果 iframe 的 DOM 与包含页面的来源不同,则无法访问它。因此,在这种情况下,您将无法判断表单是否已提交。您必须编辑 iframe 页面的 JS,并在提交表单时让弹出窗口重新加载该页面。

window.opener.location.reload()

【讨论】:

    猜你喜欢
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    相关资源
    最近更新 更多