jquery - 单击图像时在 Colorbox 中加载 iframe

标签 jquery html iframe gallery colorbox

我有两个插件:Tiles GalleryColorbox - 一个非常基本的图库设置,单击缩略图 -> 在 Colorbox 中加载完整尺寸。但是,我希望能够单击图库图像并在 Colorbox 弹出窗口的 iframe 中加载网页。

以下是常规画廊项目/图像的加载方式(完美运行):

<article class="tile category">
   <a href="path/to/image.jpg">
     <img class="item" src="path/to/thumbnail.jpg" />
     <div class="caption"></div>
   </a>
</article>

这是我尝试加载 iframe 失败的原因:

<article class="tile iframe" data-type="html">
  <a class="tile iframe" href="http://google.com">
  <img class="item" src="path/to/thumbnail.jpg" />
  </a>
</article>

这是 jQuery:

<script>
    //instantiate Final Tiles Gallery
    $("#gallery-name").finalTilesGallery({
        minTileWidth: 120,
        margin: 1,
    });
    // colorbox image size setup
    $(".tile a").colorbox({rel:'group1', maxWidth:'95%', maxHeight:'95%'
    }); 
    // colorbox iframe setup
    $(".tile iframe").colorbox({iframe:true, innerWidth:600, innerHeight:700});

</script> 

为了让 Tiles gallery 插件工作,每个都必须有一个类“tile something”。根据 Tiles gallery 文档,YouTube 视频使用 iframe 按以下方式加载:

<article id="video" class="tile ftg-set-2" data-type="video">
 <iframe class="item" width="540" height="300" src="http://www.youtube.com/embed/M4yCwlDxPtY" frameborder="0" allowfullscreen></iframe>
</article>

但是我不希望 iframe 显示在画廊本身中,我想要一个缩略图图像来引导它并且只在 Colorbox 中显示它。

如果您需要更多信息,请告诉我。任何帮助将不胜感激!

最佳答案

我设法解决了这样的问题:

      <article class="tile category">
            <a class="className" href="http://iframe-address.com">
                <img class="item" src="path/to/thumbnail.jpg" />
                <div class="caption"></div>
             </a>
    </article>

j查询:

    $(".className").colorbox({iframe:true, innerWidth:'99%', innerHeight:'99%'});

关于jquery - 单击图像时在 Colorbox 中加载 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16883964/

相关文章:

html - 使用 srcset 和大小的响应图像

html - 如何更改 <img> 标签中 svg 的描边颜色?

css - 当内容大于 div1 的大小时放置 div2

java - X-Frame-Options 支持同一域的不同子域

java - 在 Iframe 中发布服务器响应

javascript - jQuery 循环遍历 JSON 对象

jquery - 如何在 Less 而不是 jQuery 中实现自动 margin 功能

html - iFrame 在一个站点上显示不完整,而在另一个站点上显示正确?

javascript - 如何使用媒体查询删除类

java - 如何在jsp中为每个下拉列表元素添加复选框