Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>HTML Objects</h1> <h2>The Dialog Object</h2> <p>Click the button to create a DIALOG element with some text.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { const dialog = document.createElement("DIALOG"); const textNode = document.createTextNode("This is an open dialog window"); dialog.setAttribute("open", "open"); dialog.appendChild(textNode); document.body.appendChild(dialog); } </script> </body> </html>