Dialog open Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Dialog

Description

The open property sets or gets whether a dialog should be open.

This property reflects the <dialog> open attribute.

Set the open property with the following Values

Value Description
true|false? Sets whether a dialog window should be open
  • true - The dialog window is open
  • false - Default. The dialog window is not open

Return Value

A Boolean, returns true if the dialog window is open, otherwise it returns false

The following code shows how to Open a dialog window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<dialog id="myDialog" open>This is an open dialog window</dialog>

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

</body>
</html>

Related Tutorials