Page 71 - PortGPT_V2.1_C8_Flipbook
P. 71

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>

                 <TITLE> My First JavaScript </TITLE>

                 <SCRIPT TYPE="text/javascript" SRC="external.js">

                 </SCRIPT>
                 </HEAD>

                 <BODY>

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

                 </HTML>

                 Step 4:       Save the file with .html extension and open the web page in web browser. You will get
                             the same output as the previous web page.







                                                                                          Introduction to JavaScript  69
   66   67   68   69   70   71   72   73   74   75   76