Fancybox with dynamic size

Asked

Viewed 233 times

2

Hello. I’ve searched several examples of how to call a Fancybox Pop-up by passing the window size by parameters in my Function.

Ex.

AbrirPopUp(url,w, h)
{
    chamar #Fancybox(url,w,h)
}
<a href="Javascript:AbrirPopUp("janela1.htm",700,500)">Janela 1</a>

<a href="Javascript:AbrirPopUp("janela2.htm",900,400)">Janela 2</a>

<a href="Javascript:AbrirPopUp("janela3.htm",400,100)">Janela 3</a>
  • What went wrong? What was it you tried to do that didn’t work?

1 answer

2

On your link the file name should be with simple quotes, the measurements of the parameters, should also be with simple quotes, and should contain the unit of measure, in the example at low pixel

<a href="Javascript:AbrirPopUp('janela1.htm',700px,500px)">Janela 1</a>

call the fancybox in your Function by passing the parameters

<script>
    function AbrirPopUp (url, w, h) {
        $(".fast_edit").fancybox({
            href            : url,
            autoSize        : false, 
            fitToView       : false,
            width           : w,
            height          : h
        });
    }
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.