Javascript:检查页面是否在顶部 [英] Javascript: check IF page is at the top

查看:16
本文介绍了Javascript:检查页面是否在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法用 JavaScript 检查页面是否位于 scroll(0,0)?

原因是我有一个整页滑块,我需要在页面不在原点时暂停.

Reason being I've got a full page slider that I need to pause the second the page is not at origin.

这可能不一定是因为页面正在实时滚动,因为我有内部 HTML # 链接,可以将页面直接加载到滚动点,而无需实际滚动.

And it might not necessarily be because the page is being scrolled live as I've got internal HTML # links that would load the page right to a scrolled point without actually scrolling.

因此需要检查页面是否位于顶部,而不是页面是否已滚动.

So the check needs to be is the page not at the top, as opposed to, has the page been scrolled.

推荐答案

试试这个:

document.body.scrollTop === 0

这篇关于Javascript:检查页面是否在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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