DISPLAY WEBSOCKET MESSAGES
After you have a WebSocket client that can send messages to a WebSocket service, it makes sense to display the service response messages back to the web browser. Additional information, such as the connection status, error messages, and outgoing messages, is useful to display, too. The best way to do this is to create an output element and use jQuery’s append method to inject information into it. You also can use jQuery’s scrollTop method to ensure that the window is always showing the last entry, which appears at the bottom of the scrollable window.
Because the <output> tag can potentially scroll down the screen, it is a good idea to use the CSS overflow property.
This enables you to limit the height and width and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access