Open In App

HTML DOM Dialog show() Method

The DOM Dialog show() method is used to show the dialog. The Dialog element is accessed by getElementById(). It is used in HTML5. While using this method, the user can interact with other elements on the page. 

Syntax:



dialogObject.show()

Example: This example shows the working of Dialog show() Method: 




<!DOCTYPE html>
<html>
 
<body>
    <h3>
          HTML DOM Dialog show() Method
      </h3>
    <p>
          Click on the below buttons to show or close the dialog window.
      </p>
    <button onclick="showDialog()">
          Show dialog box
      </button>
    <dialog id="showDialog" style="color:green">
        Welcome to GeeksforGeeks
      </dialog>
 
    <script>
        let gfg =
        document.getElementById("showDialog");
        function showDialog() {
            gfg.show();
        }
    </script>
</body>
</html>

Output: 



 

 Supported Browsers:

Article Tags :