The question is a bit broad, I will answer what it gives.
I wanted to convert my c ++ code to JavaScript so I could use it in web pages.
It's not that simple. Although it is possible to do this, if the code was not prepared to work in the * browser, or at least it is a library that is integrated in a code prepared for this, nor wasted time.
How can I do this? For what I researched Emscripten does this, but I do not know how to use it.
Saying how to do it is very broad, it would be a manual. I suggest you study a little WebAssembly , which eliminates the need for Emscripten and solves it in a much better way.
How does it work?
It is a compiler (or transpiler then it looks like script is called asm.js to run the generated code. The performance is pretty bad, unlike WebAssembly which is even used to improve JS performance.
How to use it?
With a more specific problem you may have to answer another question. But I do not know if you still want to learn something obsolete.
What are your capabilities?
I do not know what you mean.
How to integrate generated HTML in HTML?
Too broad to answer here.