Fancybox强制滚动到顶部 [英] Fancybox force scroll to top

查看:112
本文介绍了Fancybox强制滚动到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery Fancybox插件在网站上显示一些内容。不幸的是,当点击一个链接时,加载的灯箱开始于与前一个相同的滚动位置。我尝试使用
self.scrollTo(0,0)
$ .scrollTo(0)
$('#top')。scrollTo();

I'm using the jQuery Fancybox plugin to display some content on a website. Unfortunately, when a link is clicked, the lightbox that is loaded starts at the same scroll position as the previous one. I tried using self.scrollTo(0,0) $.scrollTo(0) $('#top').scrollTo();

和其他一些方法将它推回到顶部,但似乎都没有。对此有何帮助?

and a few others methods to push it back to the top, but none have seemed to work. Any help on this?

推荐答案

Fancybox是否有某种回调?我问的原因是,灯箱可能会将滚动条重置回原来的位置,因此在灯箱完全关闭后你需要以某种方式调用scrollTo。

Does Fancybox have some sort of a callback? The reason I ask is, the lightbox is probably resetting the scroll back to the same position it left of at, so you would need to somehow call the scrollTo after the lightbox is completely closed.

另外,为什么不使用 scrollTop 而不是scrollTo(我假设是jQuery) scrollTo插件)。

Also, why not use scrollTop instead of the scrollTo (which I assume is the jQuery scrollTo plugin).

这个链接是否在灯箱内?你究竟在什么时候调用scrollTo?你有一些代码来展示你在做什么吗?

Is this link inside the lightbox? When exactly are you calling scrollTo? Do you have some code to show what you are doing?

Metropolis

Metropolis

EDIT

试试这个

$("#element").fancybox({
    onComplete: function() {
        $(document).scrollTop(0);
    }
});

这篇关于Fancybox强制滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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