2012-07-03 12 views
10

soy nuevo en la consulta j, es genial, pero estoy pegado al techo sobre cómo agregar ancho y alto a un iframe generado después del clic, usando este código: todas las sugerencias serían geniales y gracias de antemano Khadijausing fancybox set height and width

$(document).ready(function() { 
    $(".fancybox").fancybox(); 
}) 
.height = '600px'; 
+0

Cuando dice 'iframe' entendemos que está utilizando FancyBox para abrir una página HTML externa o documento, ¿verdad? – JFK

Respuesta

3

Probar:

$(document).ready(function() { 
    $(".fancybox").fancybox({"width":400,"height":300}); 
}) 
+0

Además, debe establecer el parámetro ''tipo': 'iframe'' o agregar la clase' iframe' para fancybox v1.3.4 o la clase 'fancybox.iframe' para fancybox v2.x al ancla. – JFK

6

para inicializar la ventana emergente FancyBox para el uso de un iframe, limitada a una cierta anchura y altura, se necesitan al menos tres parámetros:

jQuery

$(document).ready(function(){ 
    $(".fancybox").fancybox({ 
    'width' : 600,   // set the width 
    'height' : 600,   // set the height 
    'type' : 'iframe'  // tell the script to create an iframe 
    }); 
}); 

Usted puede leer todo acerca de las opciones disponibles en el FancyBox API Page.

1

Este tamaño de conjunto de códigos de tiempo de ejecución de fantasía dinámica @ Sólo tienes que pasar altura & anchura a lo largo de URL de la página, a la que desea establecer

Ej: demo.aspx // esta declaración llama a la función de fantasía que está presente en su página principal

 window.parent.SetFancySizeDynamic(YourPageUrl,300,200) 

    MainPage.aspx 

// sólo tiene que añadir esta función en su página principal

function SetFancySizeDynamic(fbHref, fbWidth, fbHeight) { 

     $.fancybox({ 
      'padding': 0, 
      'overlayColor': '#ccc', 
      'type': 'iframe', 
      'href': fbHref, 
      'width': fbWidth, 
      'height': fbHeight 

     }); 
    } 
16

Yo ("FancyBox"). u debe establecer autoSize en false

$(".fancybox").fancybox({'width':400, 
         'height':300, 
         'autoSize' : false}); 
+0

'tipo': 'en línea', 'autoDimensions': falso, 'ancho': 600, 'altura': 600, – Brent

+0

Funcionó para mí: aparentemente autoSize está predeterminado como falso, ya que eliminé la configuración de línea auotSize a falso , luego configure mi altura y ancho, funcionó como se esperaba. – condiosluzverde

0

Es necesario configurar autoSize en false, trabajado para mí

$ FancyBox ({ 'width': 400, 'de altura ': 300, ' autoSize ': falso});

0
jQuery(function($){  
      $(document).ready(function() { 
     $("#lightwindow").fancybox({ 
        minWidth: 250, 
        width: 250, 
        minHeight: 500, 
        height: 500, 
        'autoScale': false, 
        'autoDimensions': false, 
        'scrolling'  : 'no', 
        'transitionIn' : 'none', 
        'transitionOut' : 'none', 
        'type': 'iframe'     
       }); 
      }); 
     }); 
-1

Si todavía tiene problemas de

  width  = current.width, 
      height  = current.height, 

modificarlo de jquery.fancybox.js

2

Hey Use el código a continuación:

fancybox({ 
    afterLoad : function() { 
     $.extend(this, { 
      aspectRatio : false, 
      type : 'html', 
      width : '90%', 
      height : '90%', 
      content : '<div class="fancybox-image" style="background-image:url(' + this.href + '); background-size: cover; background-position:50% 50%;background-repeat:no-repeat;height:100%;width:100%;" /></div>' 
     }); 
    } 
}); 
0

Con iframe

$(document).ready(function() { 
     $(".fancybox").fancybox({ 
      width:600, 
      height:400, 
      type: 'iframe', 
      href : 'url_here' 
     }); 
    }) 

Sin iframe

$(document).ready(function() { 
    $(".fancybox").fancybox({ 
     width:600, 
     height:400, 
     autoDimensions: false, 
    }); 
}) 
Cuestiones relacionadas