Thursday 23 August 2018

Javascript: alert box

alert box used to display a message to user and stops execution until user press OK.

Syntax
alert(message);

alert.html
<!DOCTYPE html>

<html>
 <head>
  <title>Variables</title>
 </head>
 
 <body>
  <script type="text/javascript">
   alert("Display heading1");
  </script>
  
  <h1>heading1</h1>
  
  <script type="text/javascript">
   alert("Display heading2");
  </script>
  
  <h1>heading2</h1>
  
  <script type="text/javascript">
   alert("Display heading3");
  </script>
  
  <h1>heading3</h1>
 </body>
</html>

Open above html code in browser, you can able to see first alert with message “Display heading1”. Once you press OK, you will see the second alert box “Display heading2”. Once you press OK, You will see the alert box “Display heading3”.



Previous                                                 Next                                                 Home

No comments:

Post a Comment