运行 ❯
获取您
自有
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 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>