Dialog close() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Dialog

Description

The close() method closes the dialog.

Syntax

The following code shows how to Show and close a dialog window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>


<button onclick="showDialog()">Show dialog</button>
<button onclick="closeDialog()">Close dialog</button>

<dialog id="myDialog">This is a dialog window</dialog>

<script>
var x = document.getElementById("myDialog");

function showDialog() {/*from  ww  w. java2s.  c  o  m*/
    x.show();
}

function closeDialog() {
    x.close();
}
</script>

</body>
</html>

Related Tutorials