dongnianwo8289 2012-03-30 22:07
浏览 28
已采纳

如何在浏览器中模拟命令行界面滚动? (始终在屏幕上保留最新输出)

I've got a browser-based app that downloads a bunch of stuff from a remote server, and I'm using the str_pad trick mentioned in this answer to push output incrementally. Something like this:

Downloading records for Property 1 into table rets_property_1
Query: (181=1980-03-01T00:00:00+),(18=1980-03-01T00:00:00+) Limit: 100
Selected fields: sysid,1,2,3,4,5,6,7,8,9,10,11,13,15,16,17,18
Fetching listings from server, please wait...
Number of listings returned: 100
. Downloading images
Images found: 2
Images downloaded: 2
. Downloading images
Images found: 1
Images downloaded: 1
. Downloading images
Images found: 4
Images downloaded: 4
... etc

I want to keep the browser scrolled to the bottom at all times, with the option to scroll back up, kind of like what you'd see using the command line.

Not sure if this is an obstacle, but there's no way I can think of to have closing tags on anything because of the way the output is being sent (the closing tags wouldn't be sent until after all the other output).

echo '<html><body>'; // first output sent
$obj->download_listings(); // takes a long time, sends output incrementally
echo '</body></html>'; // too late to be useful

Is there any way to make sure the newest piece of output is always displayed on the screen (which would be at the bottom after the screen is full)? I'm open to using even the hackiest of ideas using PHP, HTML, JS, or CSS.

  • 写回答

2条回答 默认 最新

  • doukundong9652 2012-03-31 00:28
    关注

    If you position the <body> as {position:absolute;bottom:0} it's possible to mimic the command line output with new output at the bottom of the screen. But it simply scrolls off the top and isn't reachable once it's gone.

    Here's your fiddle with that change to demonstrate.

    Even using a <div> which must expand with its content, I can't get a scroll bar. But it must be possible: perhaps this will be a start.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配