See HTML5 canvas.
That's what Google Docs switched to so they could guarantee a consistent UI across different browser platforms.
For the full OS implementation see NodeOS and Runtime.js. NodeOS is a V8 runtime built on top of a very minimal linux kernel. Runtime.js is a full OS implementation from scratch written entirely in Javascript.