We can create a <dialog> element via the document.createElement()
method:
var x = document.createElement("DIALOG");
Click the button to create a DIALOG element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w. ja va 2 s .c om*/ var x = document.createElement("DIALOG"); var t = document.createTextNode("This is an open dialog window"); x.setAttribute("open", "open"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>