Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在clear js中检查页面的滚动_Javascript_Css - Fatal编程技术网

Javascript 如何在clear js中检查页面的滚动

Javascript 如何在clear js中检查页面的滚动,javascript,css,Javascript,Css,我在页面底部有一个页脚(当页面可滚动时)。我的脚本每秒检查可滚动2次 如果我想向下滚动页面以查看页脚,我不能这样做 let check_height=setInterval(function() { var height_of_logo=document.querySelector('header').offsetHeight-2; document.querySelector('footer').style.position='absolute'; var height

我在页面底部有一个页脚(当页面可滚动时)。我的脚本每秒检查
可滚动
2次

如果我想向下滚动页面以查看页脚,我不能这样做

let check_height=setInterval(function()
{
    var height_of_logo=document.querySelector('header').offsetHeight-2;
    document.querySelector('footer').style.position='absolute';
    var height_of_main=documentquerySelector('footer').offsetTop-document.querySelector('header').offsetHeight;
    var height_of_body=document.querySelector('form, table').offsetHeight+height_of_logo+2+document.querySelector('footer').offsetHeight;
    var height_of_body_real=document.body.querySelector('footer').offsetHeight+document.querySelector('footer').offsetTop;
    if(height_of_body_real<=height_of_body)
    {
        document.querySelector('main').style.height=document.querySelector('form, table').offsetHeight+'px';
        document.querySelector('footer').style.position='static';
    }
    else
    {
        document.querySelector('main').style.height=height_of_main+'px';
    }
}, 500);
check\u height=setInterval(函数()
{
标识的变量高度=document.querySelector('header')。offsetHeight-2;
document.querySelector('footer').style.position='absolute';
var height_of_main=documentquerySelector('footer')。offsetTop document.querySelector('header')。offsetHeight;
主体的变量高度=document.querySelector('表单,表格').offsetHeight+logo的高度+2+document.querySelector('页脚').offsetHeight;
var height_of_body_real=document.body.querySelector('footer').offsetHeight+document.querySelector('footer').offsetTop;

如果(车身的高度)真实请检查控制台中的此
文档.children


这里有scrollTop和更多内容。

通过获取
scrollTop
属性,可以获得每个可滚动DOM元素的滚动高度

let element = document.getElementById('foo')
console.log(element.scrollTop)

我不知道为什么,但这不起作用,这就是我问的原因。