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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度