Javascript DOM HTML Dialog show() Method

Introduction

Show a dialog window:

Click the buttons to show or close the dialog window.

View 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 w  w w . j av  a  2s  .  co  m*/
  x.show();
}

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

</body>
</html>

The show() method shows the dialog.




PreviousNext

Related