HTML streaming does not scroll |
HTML streaming does not scroll |
Protovtol |
Oct 23 2022, 10:54 PM
Post
#1
|
Group: Members Posts: 2 Joined: 23-October 22 Member No.: 28,605 |
Hi - a newbie here - my apologies.
I have an instrument with a tiny web server that continuously sends out data, wrapped in HTML, to a client that may be connected to it by HTTP. When I connect to it using Chrome, I continuously receive lines of data when they become available. I do not have to query the server every time. The new data is displayed on a line below the previous line. Problem is that Chrome does not scroll the page, so that after a while new data becomes hidden at the bottom of the page, and I have to manually scroll up to see the latest data. Is there any way to include an HTML 'force scroll' command in the stream? If not, how can I tell Chrome to scroll up automatically? Here is example code, which is sent to the client everytime new data becomes available. CODE sendtoclient("<!DOCTYPE html><html>"); sendtoclient("<head><meta name="viewport" content="width=device-width, initial-scale=1">"); sendtoclient("<link rel="icon" href="data:,">"); sendtoclient("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); sendtoclient("</style></head>"); sendtoclient("<body><h1>Pressure is: </h1><p>"); sendtoclient(ReportBuf); sendtoclient("</p></body></html>"); Note ReportBuf is a string containing the data, which is continuously being updated. Thanks to each and every reply. Protovtol This post has been edited by Protovtol: Oct 23 2022, 11:06 PM |
Christian J |
Oct 24 2022, 04:33 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Hi - a newbie here Hi and welcome! QUOTE When I connect to it using Chrome, I continuously receive lines of data when they become available. I do not have to query the server every time. That sounds like push technology. I didn't know if that's possible with HTML alone, unless the user reloads the page in the browser? QUOTE The new data is displayed on a line below the previous line. From the code example it looks like an entire web page is added every time, instead of just the ReportBuf line? That would result in broken HTML, you're only supposed to have one Doctype, HEAD and BODY section in each page. QUOTE Problem is that Chrome does not scroll the page, so that after a while new data becomes hidden at the bottom of the page, and I have to manually scroll up to see the latest data. Is there any way to include an HTML 'force scroll' command in the stream? The easiest might be to add each new line above the previous one, then there's no need to scroll. Otherwise you might add an HTML element with some ID value to the page's bottom, say: CODE <div id="end"></div> and the instruct users to use the URL "yoursite.com/data.html#end". Or you could use javascript to make the browser scroll to bottom without adding the #end hash to the URL. But I don't know if either works with Push technology. |
Lo-Fi Version | Time is now: 25th April 2024 - 03:47 AM |