Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 70 - 2609_Logicode
P. 70

    <TITLE>Internal JavaScript</TITLE>

                      </HEAD>
                      <BODY>

                      <H1>Hello World!</H1>

                      <SCRIPT>

                      alert('Hello World!');
                      </SCRIPT>

                      </BODY>

                      </HTML>
                      When you click on the OK button, the following output appears:

                      Note that the alert() function is used to display a pop-up alert with a message.

                      EXTERNAL JAVASCRIPT

                      You can write JavaScript code in a separate file, save it with a .js extension and then link it to an
                      HTML document. To do this, put the file path in the SRC attribute of the <SCRIPT> tag.
                      The following JavaScript code is used to create the external JavaScript file, named, External.js:

                      alert('Hello World!');

                         Code
                           2       Create a web page to demonstrate the concept of external JavaScript.

                      <!DOCTYPE HTML>

                      <HTML>
                      <HEAD>
                      <TITLE>External JavaScript</TITLE>

                      <SCRIPT SRC="External.js">
                      </SCRIPT>
                      </HEAD>

                      <BODY>
                      <H1>HELLO WORLD!!!</H1>

                       68   Premium Edition-VIII

| 65 66 67 68 69 70 71 72 73 74 75 |