It is simply astounding what poor feedback you got here.
Yes, you can do virtually everything in javascript. Ignore the misguided people who did not understand your situation and suggested you use jQuery. Why pull in a large library when a few lines of javascript can do the job? Do not bother to learn jQuery which is going out of style.
The key thing you did not understand is that you should create a dialog element within the body of your page, not in the document. Add an id to your body element. In your javascript, find it. Create a dialog and use appendChild to put it under body.
From there it's cake. You use document.createElement to make various button and label objects. Use appendChild to add them to your dialog.
Create a Close button and use dialog.close() method to terminate.