O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required