Page 145 - ComputerGenius_V2.1_Class8
P. 145

<HTML>
                 <HEAD>
                 <TITLE> My First JavaScript </TITLE>
                 <SCRIPT TYPE="text/javascript">
                 alert("Hello World!");
                 </SCRIPT>

                 </HEAD>
                 <BODY>
                 This message box is displayed using JavaScript.
                 </BODY>
                 </HTML>

                 Step 3    Save the above code with .html and open this file in any web browser.

































                 The web browser displays the alert message ‘Hello World’.

                 Creating a Web Page with External JavaScript


                 To use external JavaScript, follow the given steps:




                 Step 1    Open the Notepad and type the following line:
                          alert("Hello World");

                 Step 2    Save the file with .js extension.

                 Step 3    Open another Notepad and type the following code:
                 <HTML>
                 <HEAD>



                                                                                   Introduction to JavaScript  143
   140   141   142   143   144   145   146   147   148   149   150