English 中文(简体)
Javascript - Dialog Boxes
  • 时间:2024-12-22

JavaScript - Dialog Boxes


Previous Page Next Page  

JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise and alert, or to get confirmation on any input or to have a kind of input from the users. Here we will discuss each dialog box one by one.

Alert Dialog Box

An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires to enter some text but the user does not provide any input, then as a part of vapdation, you can use an alert box to give a warning message.

Nonetheless, an alert box can still be used for friendper messages. Alert box gives only one button "OK" to select and proceed.

Example

<html>
   <head>   
      <script type = "text/javascript">
         <!--
            function Warn() {
               alert ("This is a warning message!");
               document.write ("This is a warning message!");
            }
         //-->
      </script>     
   </head>
   
   <body>
      <p>Cpck the following button to see the result: </p>      
      <form>
         <input type = "button" value = "Cpck Me" oncpck = "Warn();" />
      </form>     
   </body>
</html>

Output