开发者

Fancybox - Opening a link inside a fancybox into the same fancybox?

On my site I have a fancybox that contains the contents of a hidden <div> on the page. This hidden <div> contains a link to an external site.

Is it possible to have this link open in the already open fancybox?

The code I currently have is as follows:

$("#lightbox-link").fancybox({
    'scrolling' : 'no',
    'width': 5000, 
    'height': 2000,
    'onComplete': function() { 
        $('a#yes').click(function() {
            $.cookie("survey",开发者_开发技巧 "dismissed", {expires: 365});
            $.fancybox.close();
        });
        $('a#no').click(function() {
            $.cookie("survey", "big-snooze", {expires: 14});
            $.fancybox.close();
        });
        $('a#later').click(function() {
            $.cookie("survey", "snooze", {expires: 1});
            $.fancybox.close();
        });
    },
    'content' : $("#lightbox-content").html()
});

Thanks!


Fancybox's built-in 'href' attribute loads content relative to the current website. As a result loading an external web page shows missing graphics. I came up with the following solution using an iframe. The transition to the external website appears nice and smooth.

<script type="text/javascript">
    $(function () {   //jquery onload
        $.fancybox('<div id="myfancy"><a href="#" onclick="javascript:openlink(\'http://www.cleversavers.com\');">Click me</a></div>'
            , {});
    });
    function openlink(url) {
        $.fancybox('<iframe id="myi" src="' + url + '" frameborder="0" height="400" width="600" />', {});
    }
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜