As I understand you're wanting to create something similar to OS.js?
It begs the question of why? The way a huge amount of people use an operating system these days is simply to host a web browser, so it doesn't make all that much sense to run another OS inside the browser. A full OS inside a browser would also be extremely slow and memory heavy, due to the bloated nature of JavaScript.