Php 页面加载时滚动至底部,但允许在顶部滚动

Php 页面加载时滚动至底部,但允许在顶部滚动,php,jquery,css,Php,Jquery,Css,我想在页面加载时将divbottom滚动到页面底部,但也希望在需要时向上滚动,以了解如何在没有任何动画的情况下存档此文件我如何实现此目的 echo“$from_username$message” <script> $( document ).ready(function() { var d = $('#div1'); d.scrollTop(d.prop("scrollHeight"));

我想在页面加载时将div
bottom
滚动到页面底部,但也希望在需要时向上滚动,以了解如何在没有任何动画的情况下存档此文件我如何实现此目的
echo“$from_username
$message

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>

函数scrollpage(){
函数f()
{
滚动到(0,i);
如果(状态==0){
i=i+40;
如果(i>=高度){status=1;}
} 
设置超时(f,0.01);
}f();
}
var Height=document.documentElement.scrollHeight;
变量i=1,j=高度,状态=0;
滚动页面();
这就是我到目前为止所拥有的,我可以自动向下滚动,但当我想向上滚动时,我不能向上滚动,如果我想向上滚动,我可以做什么?

这是我找到代码的地方,我需要为您组合这些代码。
    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>

$(文档).ready(函数(){
变量d=$('#div1');
d、 滚动顶部(d.prop(“滚动高度”);
log(“在底部!”);
});
顶

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>
一些文本

一些文本

一些文本

一些文本

一些文本

一些文本

一些文本

一些文本

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>
底部

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>
div下的文本

    <script>
        $( document ).ready(function() { 
            var d = $('#div1');
            d.scrollTop(d.prop("scrollHeight"));
            console.log("at the bottom!");
        });
    </script>
    </head>
    <body>
    <p>top</p>
    <div style="max-height: 200px;">
    <div id='div1' style='background-color:grey;width:200px;overflow:scroll;overflow-x:hidden;max-height:200px;'>
    <p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p><p>some text</p></div>
    </div>
    <p>bottom</p>
    <p>text under the div</p>
    </body>
</html>

您经常调用它,因为您的scrollpage();电话中没有任何内容。你是对的,所以你知道我该怎么做吗?为正在处理的那个特别的div向上滚动。给我5分钟我们开始。使用我的新解决方案,你就可以开始了。我想现在一切都正常了吧?