admin管理员组文章数量:1403522
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?
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?
Share Improve this question asked Apr 8, 2010 at 18:02 Brad HermanBrad Herman 10.7k7 gold badges30 silver badges33 bronze badges2 Answers
Reset to default 4I had the same problem. Metropolis, I used a similar solution, but instead of $(document).scrollTop(0) I targeted $("#fancybox-inner").scrollTop(0) which worked for me.
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 pletely closed.
Also, why not use scrollTop instead of the scrollTo (which I assume is the jQuery scrollTo plugin).
Is this link inside the lightbox? When exactly are you calling scrollTo? Do you have some code to show what you are doing?
Metropolis
EDIT
Try this
$("#element").fancybox({
onComplete: function() {
$(document).scrollTop(0);
}
});
本文标签: javascriptFancybox force scroll to topStack Overflow
版权声明:本文标题:javascript - Fancybox force scroll to top - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744420953a2605450.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论