将html中的fancybox关闭按钮更改为一页滚动网站

Change fancybox close button within html for one page scroll site

本文关键字:一页 滚动 网站 html 中的 fancybox 关闭按钮      更新时间:2023-09-26

我有一个页面滚动网站(如f.ex.fullPage.js、fullContent.js),其中使用fancybox打开新内容。

<a class="fancybox" rel="group"  href="#content">
    <img src="img/thumb.jpg" alt="" />
</a>
<div id="content" style="display:none;">
    // content
</div>

fancybox中的关闭按钮默认为绝对位置,这在我的情况下是不可接受的——关闭按钮需要在特定的分区内。

触发关闭的一种方法如下:

<a href="#" onClick="parent.jQuery.fancybox.close();">close</a>

它确实关闭了内容,但它会下降到网站的起始位置,而不是触发粉丝盒的部分。有什么想法可以让关闭按钮工作,这样在关闭内容后,观点就不会改变
有趣的是,通过js启用的默认关闭按钮将视点保持在打开fancybox之前的位置。

$(".fancybox").fancybox({
    closeBtn   : true,
});

提前谢谢。

使用此:

<a href="javascript:void(0);" onClick="parent.jQuery.fancybox.close();">close</a>

这将停止浏览器向上滑动。

或者你也可以试试:

<a href="#nogo"> or <a href="javascript:;">