The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> HTML streaming does not scroll
Protovtol
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 24 2022, 04:33 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,205
Joined: 10-August 06
Member No.: 7



QUOTE(Protovtol @ Oct 24 2022, 05:54 AM) *

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? unsure.gif

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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th November 2022 - 11:23 AM