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

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

问题描述

是否可以使用JavaScript检查页面是否位于 scroll(0,0)上?

Is there a way to check, with JavaScript, if the page is at 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:检查IF页面在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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