Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 78 - 2609_Logicode
P. 78

    <TITLE>Using Function</TITLE>

                      <SCRIPT>
                      function changeColour()
                      {

                      document.body.style.backgroundColor = "lightblue";
                      }

                      </SCRIPT>
                      </HEAD>
                      <BODY>

                      <H1>Click the Button to Change the Background Colour</H1>

                      <BUTTON onclick="changeColour()"> Change Colour </BUTTON>
                      </SCRIPT>
                      </BODY>

                      </HTML>
                      The output of the preceding HTML code is as follows:

                      The function changes the background colour of the web page to light blue using JavaScript.

                                JAVASCRIPT POPUP BOXES

                      The JavaScript popup boxes are used to interact with users by displaying messages or requesting
                      input. There are three main types of popup boxes: Alert Box, Confirm Box and Prompt Box.

                      ALERT BOX

                      The Alert box displays a message and can only be closed by the user clicking the OK button.
                      This box is often used to show important information or warnings. The alert() function is used to
                      trigger the alert box.

                      The following HTML code demonstrates the use of Alert Box in JavaScript:

                       76   Premium Edition-VIII

| 73 74 75 76 77 78 79 80 81 82 83 |