jQuery Fancybox iframe 尺寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2464870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:34:07  来源:igfitidea点击:

fancybox iframe dimension

jqueryfancyboxdynamic-resizing

提问by iperdiscount

In the fancybox homepage (http://fancybox.net/home) there is an example that opens an iFrame dimensioned as the 75% of the screen.

在fancybox 主页( http://fancybox.net/home) 中有一个示例,它打开一个尺寸为屏幕75% 的iFrame。

I can't get it by modifying the width and height properties on the .js file as described on the site.

我无法通过修改网站上描述的 .js 文件的宽度和高度属性来获得它。

回答by user348402

You should try this:

你应该试试这个:

$('iframeLink').fancybox({
'width':300,
'height':200,
'type':'iframe',
'autoScale':'false'
});

回答by Fred

Hi I just read through all of these and I had to take bits and pieces of what everyone else wrote to get it to work. I wanted a window 600 by 410

嗨,我只是通读了所有这些,我不得不从其他人写的东西中获取一些点点滴滴才能让它发挥作用。我想要一个 600 x 410 的窗口

First change the java scriptI dealt with the file: jquery.fancybox-1.3.4.js(this may change with later versions) under defaults set your height and width

首先更改我处理文件的java脚本jquery.fancybox-1.3.4.js(这可能会随着更高版本而改变)在默认设置下设置您的高度和宽度

width : 600, height : 410,

宽度:600,高度:410,

*then change the script on your webpage

*然后更改您网页上的脚本

$("#various3").fancybox({

$("#various3").fancybox({

'width' : 600,

“宽度”:600,

'height' : 410,

'高度':410,

'autoScale' : false,

'自动缩放':假,

'type' : 'iframe'

'类型':'iframe'

please note the size is not in single quotes!I wasted an hour before I saw this mistake.

请注意尺寸不是单引号!我浪费了一个小时才看到这个错误。

This should help. Now if someone can tell me how to get this iframe to pop up on page load.

这应该有帮助。现在,如果有人能告诉我如何让这个 iframe 在页面加载时弹出。

回答by snez

I'm guessing you should set the fancybox height as

我猜你应该将fancybox高度设置为

$(window).height() * 0.75 

but I would personally prefer to do it with pixels like

但我个人更喜欢用像素来做

$(window).height() - 80

回答by Lewis

I had the same problem and ended up adjusting the default dimensions at the bottom of the fancybox js file - "frameWidth:800,frameHeight:600"

我遇到了同样的问题,最终调整了fancybox js文件底部的默认尺寸 - “frameWidth:800,frameHeight:600”

They also mention you can do this on the fancybox site:

他们还提到你可以在fancybox网站上做到这一点:

You can pass options as key/value object to fancybox() function or modify them at the bottom of FancyBox JS file

您可以将选项作为键/值对象传递给fancybox() 函数或在FancyBox JS 文件的底部修改它们

回答by bizzr3

but my fancybox work with ajax and so i can't change fancy size !

但是我的fancybox 与ajax 一起工作,所以我不能改变花哨的大小!

$('iframeLink').fancybox({ 'width':300, 'height':200, 'type':'ajax', 'autoScale':'false' });

$('iframeLink').fancybox({ 'width':300, 'height':200, 'type':'ajax', 'autoScale':'false' });

回答by Daniel Comp

I've got version 2.14 and this is what works for me.

我有 2.14 版,这对我有用。

$(document).ready(function() {
    $(".iframe").fancybox({
    type: 'iframe',
    'padding' : 0,  
    'autoSize': false,      
    'width': 650, 
    'height': 520
    });
});

回答by M M

By simply changing the value of type from 'iframe' to 'ajax' , solve the problem .

只需将 type 的值从 'iframe' 更改为 'ajax' ,即可解决问题。

$('Selector').fancybox.open({
                href : 'iframe.html',
                type : 'ajax',  //from type : 'iframe',
                padding : 0     
            });

Now it use the height & width of class described for the body of iframe.html file. So auto manipulated.

现在它使用为 iframe.html 文件主体描述的类的高度和宽度。所以自动操纵。