运行时刷新:
我有一个不断运行的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果“滚动”的意思是“滚动浏览器视口”,那么这是客户端的东西。
我强烈建议您使用 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.