Javascript DOM HTML Dialog Object get

Introduction

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.

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  w  ww  . ja v a 2  s.  co  m*/
  var x = document.getElementById("myDialog");
  x.open = true;
}
</script>

</body>
</html>



PreviousNext

Related