Javascript DOM HTML Dialog open Property set

Introduction

Open a dialog window:

document.getElementById("myDialog").open = true;

Click the button to open the dialog window.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>
<dialog id="myDialog">This is an open dialog window</dialog>

<script>
function myFunction() {/*from ww w  . j a  va  2  s .  c o m*/
  document.getElementById("myDialog").open = true;
}
</script>

</body>
</html>

The open property opens or closes a dialog box.

This property mirrors the <dialog> open attribute.

The open property accepts and returns a boolean value.

Value Description
trueThe dialog window is open
false Default. The dialog window is not open

The open property returns true if the dialog window is open, otherwise it returns false.




PreviousNext

Related