HTML and CSS Reference
In-Depth Information
browser. Cross-Document Messaging provides asynchronous messages passing between
JavaScript contexts.
The HTML5 specification for Cross-Document Messaging also clarifies and refines
domain security by introducing the concept of origin , which is defined by a scheme, host,
and port. Basically, two URIs are considered from the same origin if and only if they have
the same scheme, host and port . The path is not considered in the origin value.
The following examples show mismatched schemes, hosts, and ports (and therefore
different origins):
https:// and http://
http:// and http:// 8080 and 8081
The following examples are URLs of the same origin: and .
Cross-Document Messaging overcomes the same-origin limitation by allowing
messages to be exchanged between different origins. When you send a message, the
sender specifies the receiver's origin and when you receive a message the sender's origin
is included as part of the message. The origin of the message is provided by the browser
and cannot be spoofed. On the receiver's side, you can decide which messages to process
and which to ignore. You can also keep a “white list and process only messages from
documents with trusted origins.
Cross-Document Messaging is a great example of where the HTML5 specification
simplifies communication between web applications with a very powerful API. However,
its focus is limited to communicating across windows, tabs, and iFrames. It does not
address the complexities that have become overwhelming in protocol communication,
which brings us to WebSocket.
Ian Hickson, the lead writer of the HTML5 specification, added what we now call
WebSocket to the Communication section of the HTML5 specification. Originally called
TCPConnection, WebSocket has evolved into its own independent specification. While
WebSocket now lives outside the realm of HTML5, it's important for achieving real-
time connectivity in modern (HTML5-based) web applications. WebSocket is also often
discussed as part of the Connectivity area of HTML5. So, why is WebSocket meaningful
in today's Web? Let's first take a look at older HTTP architectures where protocol
communication is significant.
Overview of Older HTTP Architectures
To understand the significance of WebSocket, let's first take a look at older architectures,
specifically those that use HTTP.
HTTP 101 (or rather, HTTP/1.0 and HTTP/1.1)
In older architectures, connectivity was handled by HTTP/1.0 and HTTP/1.1. HTTP is
a protocol for request-response in a client/server model, where the client (typically a
web browser) submits an HTTP request to the server, and the server responds with the
Search WWH ::

Custom Search