Fancybox - 将fancybox内的链接打开到同一个fancybox中? [英] Fancybox - Opening a link inside a fancybox into the same fancybox?

查看:76
本文介绍了Fancybox - 将fancybox内的链接打开到同一个fancybox中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个fancybox,其中包含页面上隐藏的< div> 的内容。这个隐藏的< div> 包含指向外部网站的链接。

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.

是否可以打开此链接在已打开的fancybox中?

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

我目前的代码如下:

$("#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()
});

谢谢!

推荐答案

Fancybox的内置href属性将内容 relative 加载到当前网站。因此,加载外部网页会显示缺少的图形。我使用iframe想出了以下解决方案。向外部网站的过渡看起来很顺利。

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>

这篇关于Fancybox - 将fancybox内的链接打开到同一个fancybox中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆