如何让 featherlight window 脱离 iframe 并显示在父级中?
How can I have a featherlight window escape a iframe and show in the parent?
我有一个 iframe,我想打开 featherlight window。但是我无法让 featherlight window 定位到父页面,它只会显示在 iframe 中。
我在父级和 iframe 中都启用了 featherlight,并且都在工作。
我尝试添加 target="_parent" 但它继续在 iframe 中打开。知道如何解决这个问题吗?
这是在iframe中调用featherlight box的代码:
<a target="_parent" href="//google.com" data-featherlight data-featherlight-type="iframe">Test Click</a>
要求:
- 一切都在同一个域或允许跨域
- 父框架已 featherlight.css 加载
解决方案:
<a href="#" id="clickme">Test Click</a>
...
$("#clickme").featherlight({iframe: '//google.com',root:window.parent.document.body});
注:
这是一个错误,因为文档说 root 需要一个 String
root - String: 'body' This selector specified where the featherlight
should be appended.
但是如果我们看一下 source it's not checking what it's passing into appendTo
open: function(event){
var self = this;
self.$instance.hide().appendTo(self.root);
appendTo
接受类型:选择器或 htmlString 或元素或数组或 jQuery.That 是我们可以为父文档传入选择器的原因。
我有一个 iframe,我想打开 featherlight window。但是我无法让 featherlight window 定位到父页面,它只会显示在 iframe 中。
我在父级和 iframe 中都启用了 featherlight,并且都在工作。
我尝试添加 target="_parent" 但它继续在 iframe 中打开。知道如何解决这个问题吗?
这是在iframe中调用featherlight box的代码:
<a target="_parent" href="//google.com" data-featherlight data-featherlight-type="iframe">Test Click</a>
要求:
- 一切都在同一个域或允许跨域
- 父框架已 featherlight.css 加载
解决方案:
<a href="#" id="clickme">Test Click</a>
...
$("#clickme").featherlight({iframe: '//google.com',root:window.parent.document.body});
注:
这是一个错误,因为文档说 root 需要一个 String
root - String: 'body' This selector specified where the featherlight should be appended.
但是如果我们看一下 source it's not checking what it's passing into appendTo
open: function(event){
var self = this;
self.$instance.hide().appendTo(self.root);
appendTo
接受类型:选择器或 htmlString 或元素或数组或 jQuery.That 是我们可以为父文档传入选择器的原因。