如何将fancybox调整为自定义创建的iframe大小 [英] How to make fancybox resize to custom created iframe size

查看:110
本文介绍了如何将fancybox调整为自定义创建的iframe大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使fancybox尺寸与手动创建"的iframe的内容尺寸匹配.

I want to make the fancybox dimensions match the content size of a "manually created" iframe.

我尝试了此操作: http://jsfiddle.net/ystLD/3/

但是它不起作用,现在我有点卡在这里.

But it doesn't work and now I'm kinda stuck here.

有人知道该怎么做吗?

谢谢.

推荐答案

手动创建" iframe的缺点是fancybox并不真正知道内容type在处理什么.我宁愿使用选项type: "iframe"打开fancybox.

A "manually created" iframe has the disadvantage that fancybox doesn't really know what type of content is dealing with. I would rather open fancybox with the option type: "iframe".

然后,我认为您可以根据iframe的内容重新调整大小的大小的唯一方法是硬编码iframe中打开的页面内的尺寸,或者在htmlbody或类似

Then, the only way I can think you can re-size fancybox according to the contents of the iframe is hard-coding the dimensions inside the page opened within the iframe, either in the html, body or a wrapper container like

<html style="width: 800px; height: 650px;">

然后您可以使用beforeShow回调来获取iframe的尺寸,例如

then you could use the beforeShow callback to get the dimensions of the iframe like

  beforeShow: function(){
   this.width = $('.fancybox-iframe').contents().find('html').width();
   this.height = $('.fancybox-iframe').contents().find('html').height();
  }

如果您不拥有打开的页面,并且无法对它的尺寸进行硬编码,则仍然可以尝试获取htmlbody标记的innerWidth()innerHeight(),但是它确实可以您可以在此分叉的小提琴

If you don't own the opened page and you cannot hard-code its dimension, you still can try getting the innerWidth() and innerHeight() of the html or body tag, but it can be really buggy as you can see in this forked fiddle

这是对其他人有用的答案 https://stackoverflow.com/a/10776520/1055987

Here is the answer that worked for someone else https://stackoverflow.com/a/10776520/1055987

这篇关于如何将fancybox调整为自定义创建的iframe大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆