【问题标题】:Busting out of iframe from source page to display modal on parent (top) page从源页面退出 iframe 以在父(顶部)页面上显示模式
【发布时间】:2015-03-10 08:37:09
【问题描述】:

当用户单击 iframe 中的图像时,我试图让模态窗口从 iframe 中跳出到首页,这将在主(父)页面上显示视频。我有以下内容,但不确定如何实现 JavaScript 以将模态窗口从 iframed 页面推送到首页。

这是将进入父页面的 iframe 代码:

<iframe id="rtv-preview-frame" src="syndicateplayer.html" name="preview-frame" frameborder="0" noresize="noresize"></iframe>

我试图弄清楚我需要在我的syndicateplayer.html 页面上拥有什么,以便将模式的内容作为顶部的模式窗口推送到首页。环顾一些选项,看起来我需要在 iframe 中的页面上使用类似于此的内容:

var $jParent = window.parent.jQuery;
var dlg1 = $jParent('.rtv-video');
dlg1.dialog();

我已经尝试过了,但无法让 div 在点击时从 iframe 中推出。有什么建议吗?

【问题讨论】:

  • 或许这会有所帮助:stackoverflow.com/questions/3381920/…,下次尝试搜索
  • 看看这个问题。第二个答案。您可以在 iframe 上允许全屏显示。 stackoverflow.com/questions/17417517/…
  • @DaniëlTulp - 我进行了搜索,但在我的查询中没有出现。
  • @MaxBaldwin,问题不在于全屏,而在于如何将 div 从 iframed 内容推送到父页面。
  • @Matt 由于浏览器安全原因,这是不可能的。 iframe 不能与它之外的任何东西交互。您唯一的选择是具有透明背景的全屏,或者您可以尝试使用 postmessage 在 iframe 之外触发和事件。如果 iframe 中发生某些事情,则向父窗口发送一条 postmessage,告诉它根据收到的 post 消息触发一个事件。 developer.mozilla.org/en-US/docs/Web/API/Window.postMessage

标签: jquery iframe framebusting


【解决方案1】:

我找到的解决方案是使用http://www.ericmmartin.com/projects/simplemodal/,并使用它将模态从iframe推送到父级:open modal window from iframe into the parent

【讨论】:

    猜你喜欢
    • 2015-04-27
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 2014-02-09
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多