Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fancybox: iframe doesn't work

Very simple test.html page:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript" src="fancybox/jquery.fancybox.pack.js"></script>

    <link rel="stylesheet" href="fancybox/jquery.fancybox.css" type="text/css" media="screen"/>

    <script type="text/javascript">
        $(document).ready(function () {
            /* This is basic - uses default settings */

            $("a.iframe").fancybox();

        });
    </script>
</head>
<body>
<a class="iframe" href="http://www.google.be/">This goes to iframe</a>
</body>
</html>

Yet, fancybox just won't work... The references to the js file and css are correct. JQuery functions normally. But clicking the link acts just a normal link. Ie: I get redirect to google.be. FYI: It's not just with google, it's with every single URL I put there. What am I missing here?

like image 586
Matthias Avatar asked Dec 13 '12 20:12

Matthias


People also ask

How do I add an iframe to fancybox?

$(function() { $(". fancyboxIframe"). fancybox({ maxWidth : 900, maxHeight : 600, fitToView : false, width : '90%', height : '90%', autoSize : false, closeClick : false, openEffect : 'none', closeEffect : 'none', iframe: { scrolling : 'auto', preload : true } }); });


1 Answers

I had success changing the class on the anchor to fancybox fancybox.iframe.

<a class="fancybox fancybox.iframe" href="http://www.google.be/">This goes to iframe</a>
<script type="text/javascript">
    $(document).ready(function() {

        $('a.fancybox').fancybox();

    });
</script>

No idea why this is the case but it worked for me.

Edit: also need to update to a recent version of jQuery

like image 198
imjared Avatar answered Oct 23 '22 06:10

imjared