It’s not really possible to do this in HTML/Javascript; there’s to much complex code to be able to do it safely and be to able to test it. When I started coding it could run as an applet (no longer supported in most browsers) or via WebStart (which later started to require a code-signing certificate - which I can’t afford).
There is a way to play in browser still though.