Chapter 4. Messaging: communicating to and from scripts in HTML5
Chapter 4 at a glance
Description, methods, and so on |
Page |
|
---|---|---|
Server-sent events | Creating events in the browser from the server: | |
|
111 | |
|
111 | |
WebSockets | Two-way, event-driven communication: | |
|
116 | |
|
125 | |
Cross-document messaging | Communication between scripts in different windows: | |
|
126 | |
|
126 |
Look for this icon throughout the chapter to quickly locate the topics outlined in this table.
This chapter covers
- Server-sent events and event-driven communications from the server
- WebSockets for bidirectional, event-driven communication
- Client-side messaging between pages from different domains
In the last decade, the web has moved from communication based on uploading static content, similar to the traditional print publishing model, to a real-time communication system where tweets and friendings are instantly announced to hundreds of followers. We’ve all become so used to dynamically updating web pages that we don’t realize most of this is built as a series of hacks on top of HTML4 and HTTP 1.0/1.1. HTML5 cleans up these hacks by providing well-defined APIs for messaging—between the browser and web servers and between different iframes or other objects loaded in the browser.