Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 105 - CodePilot V5.0 C8
P. 105

    The basic syntax of the <SCRIPT> tag is as follows:

                     <SCRIPT TYPE="text/javascript" SRC="path of the JavaScript file/ File
                     name"></SCRIPT> where,
                         TYPE: This attribute  specifies  the  type  of script
                        language. For JavaScript, it’s typically “text/javascript”,

                        but this is optional in HTML5.                                  Some other values of the TYPE
                                                                                         attribute are “text/css” and
                         SRC: This attribute  specifies  the  URL  or path  of an              “text/vbscript”.
                        external JavaScript file to be linked.

                     In an HTML document, JavaScript can be integrated in three distinct places, which are as follows:

                         In the body: The script runs as the page loads and the output appears in the HTML content.

                         In the head (as a function): Scripts are written as functions, which can be called from anywhere
                        else in the page.
                         As an external file: JavaScript code can be written in a separate file with a .js extension. This
                        file is linked to the HTML document using the <SCRIPT> tag.

                            TYPES OF JAVASCRIPT

                     In HTML, you can use JavaScript in two ways-internally and externally.

                     INTERNAL JAVASCRIPT
                     When JavaScript code is written within the HTML web page then it is called internal JavaScript.

                     You use the <SCRIPT> and </SCRIPT> tags to place the JavaScript code either in the <HEAD>
                     or <BODY> tag of the HTML document. The syntax to add internal JavaScript is:

                     <HEAD>                                                    <BODY>
                     <SCRIPT>                                                  <SCRIPT>
                     JavaScript code                                           JavaScript code
                                                             OR
                     .....                                                     .....
                     </SCRIPT>                                                 </SCRIPT>
                     </HEAD>                                                   </BODY>

                        Code
                          1      Create a web page to demonstrate the concept of internal JavaScript.

                     <!DOCTYPE HTML>

                     <HTML>

                     <HEAD>
                     <TITLE>Internal JavaScript</TITLE>

                     </HEAD>

                                                                                                                      103
                                                                                                JavaScript for Beginners

| 100 101 102 103 104 105 106 107 108 109 110 |