运行时刷新:

发布于 2024-12-07 09:11:03 字数 287 浏览 6 评论 0原文

我有一个不断运行的 php 脚本,在此期间我正在查看带有日志的网页。有什么办法可以在刷新时自动滚动到最后一个条目吗?

我的冲洗功能(我可以让它工作的唯一方法):

function flush2 (){
    echo(str_repeat(' ',256));
    if (ob_get_length()){
        @ob_flush();
        @flush();
        @ob_end_flush();
    }
    @ob_start();
}

I've got a php script running constantly, during which I'm looking at a webpage with the logs. Is there any way to automatically scroll to the last entry when flushing?

My flush function (only way I could make it work):

function flush2 (){
    echo(str_repeat(' ',256));
    if (ob_get_length()){
        @ob_flush();
        @flush();
        @ob_end_flush();
    }
    @ob_start();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2024-12-14 09:11:03

如果“滚动”的意思是“滚动浏览器视口”,那么这是客户端的东西。

我强烈建议您使用 AJAX 定期轮询返回“新”内容的 PHP 脚本(我不知道它在示例中查看什么),并且每次它获取一些新条目时,它都会在以下位置创建一个新的 DOM 元素:页面底部,然后向下滚动页面。

If with "scroll" you mean "scroll the browser viewport", this is client-side stuff.

I strongly suggest you to use AJAX to periodically poll a PHP script that returns the "new" stuff (I don't know what it is looking at the example), and everytime it gets some new entry, it creates a new DOM element at the bottom of the page, and scrolls the page down.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文