【问题标题】:display a new content in the jquery fancybox在 jquery fancybox 中显示新内容
【发布时间】:2014-07-23 16:40:32
【问题描述】:

我有一个 jQuery fancybox 弹出窗口,效果很好。 假设弹出窗口包含一个链接<a href="http://example.com/foo/bar.html">show another content of this fancybox</a>

当你点击那个链接时,fancybox 弹出框消失,整个浏览器显示http://example.com/foo/bar.html 页面(有道理)。

此解决方案也不起作用:

<a href="#" onclick="alert('we are on the way to change the content of the fancybox');self.parent.location='http://example.com/foo/bar.html';alert('new content should be applied already');return false;">You are clicking on the link in the fancybox to apply a new content to this fancybox</a>

任何建议如何在同一个花式框弹出窗口中用新内容替换旧内容?谢谢。

刚刚添加:似乎我正在使用的一半:

$(".fancybox-inner").load("http://example.com/foo/bar.html");

我是在正确的轨道上还是可以以更好的方式完成? 谢谢。

【问题讨论】:

  • 你想要什么?你想在点击时在fancybox上显示锚的内容吗?
  • @Runcorn 对。我想在fancybox中显示example.com/foo/bar.html的内容。包括锚点在内的所有以前的内容都应该被删除。
  • 如果你也发布你的 jQuery 代码你会怎么想?

标签: javascript jquery html popup fancybox


【解决方案1】:

如果您想使用自己的内容而不是 div 中的内容,您可以使用 content 或 href 内容(内容用于任何内容,href 用于图像)

$('.my-lightbox').click(function () {
    $('.my-lightbox').fancybox({
        padding: 20,
        prevEffect: 'none',
        nextEffect: 'none',
        href: "your image here",
        //content: "your content here"
    });

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多