HTML and CSS Reference
In-Depth Information
Dropping an image to the browser and sending it to the server
Receiving data as ArrayBuffers is fairly simple. Note that you check using in-
stanceof , rather than the strict equal operator.
socket.onmessage = function(event) {
if ( instanceof ArrayBuffer) {
var buffer =;
Blobs ( Binary Large Objects ) contain totally raw data in their most native form. A
blob might theoretically be anything, even a non-JavaScript object. As a result, in-
terpreting blob data might be quite tricky. As a thumb rule, you'd better know exactly
what the server is supposed to send, otherwise you'll need to make fairly non-con-
crete assumptions.
However, the big advantage of blob data is their file size. Binary format is machine-
level format, so there are almost no abstraction layers used that would increase its
When you transmit multimedia over the web, you need the highest speed possible,
in order to achieve the best user experience. The WebSocket blobs do not create
extra burden for your Internet connection and they rely on the client for proper inter-
Following code shows how you can display an incoming image, sent as a set of raw
socket.onmessage = function(event) {
if ( instanceof Blob) {
// 1. Get the raw data.
var blob =;
// 2. Create a new URL for the blob object.
Search WWH ::

Custom Search