The Dialog object represents an HTML <dialog> element.
We can access a <dialog> element by using document.getElementById()
:
var x = document.getElementById("myDialog");
Click the button to open the dialog window.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <dialog id="myDialog">This is an open dialog window</dialog> <script> function myFunction() {/*from w ww . ja v a 2 s. co m*/ var x = document.getElementById("myDialog"); x.open = true; } </script> </body> </html>